#include <iostream>
#define LLL unsigned long long
using namespace std;
string a;
int tabpom[]={0,6,11,16,20,25,30,35,39,44,49,54,59,63,68,73,78,83,87,92,97,102};
LLL mod=1ULL,rest=0,ppprev=0,curr=1,x;
int main() {
ios_base::sync_with_stdio(0);
cin>>a;
for(int i=0;i<a.length();i++){
mod*=10;
rest=rest*10+a[i]-'0';
}
// atoi(a);
int tmp=rest%8;
if(a.length()>2){
if((tmp==4)||(tmp==6)){
cout<<"NIE";
return 0;
}
}
for(LLL i=2;(i<15*mod);i++){
if(curr==rest){
if(i>tabpom[a.length()-1]){
//znalezione
cout<<i-1;
return 0;
}
}
tmp=curr;
curr=(ppprev+curr)%mod;
ppprev=tmp;
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <iostream> #define LLL unsigned long long using namespace std; string a; int tabpom[]={0,6,11,16,20,25,30,35,39,44,49,54,59,63,68,73,78,83,87,92,97,102}; LLL mod=1ULL,rest=0,ppprev=0,curr=1,x; int main() { ios_base::sync_with_stdio(0); cin>>a; for(int i=0;i<a.length();i++){ mod*=10; rest=rest*10+a[i]-'0'; } // atoi(a); int tmp=rest%8; if(a.length()>2){ if((tmp==4)||(tmp==6)){ cout<<"NIE"; return 0; } } for(LLL i=2;(i<15*mod);i++){ if(curr==rest){ if(i>tabpom[a.length()-1]){ //znalezione cout<<i-1; return 0; } } tmp=curr; curr=(ppprev+curr)%mod; ppprev=tmp; } return 0; } |
English