Last active
December 25, 2015 12:49
-
-
Save ukasiu/6979700 to your computer and use it in GitHub Desktop.
No, mała liczba, to sprawdziłem metodą dość brutalną podstawiając pod modulo dość dużą potęgę 10 i też mi wyszło 8. Pytanie tylko jak zrobić krótki a zarazem poprawny kod ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #define ULL unsigned long long | |
| using namespace std; | |
| ULL tenn(ULL n) { | |
| ULL w=1,ten=1; | |
| while(w<=n) { | |
| w*=5; ten*=10; | |
| } | |
| return ten; | |
| } | |
| int main() { | |
| ULL n; | |
| cout << "Podaj n" << endl; | |
| cin >> n; | |
| ULL modulo=tenn(n); | |
| ULL wynik=1; | |
| for(int i=1;i<=n;i++) { | |
| wynik *= i; | |
| while(wynik%10==0) { | |
| wynik /= 10; | |
| } | |
| wynik %= modulo; | |
| } | |
| cout << wynik%10 << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment