标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1672 Accepted Submission(s): 463
1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 #include<algorithm> 6 #include<cmath> 7 #include<queue> 8 #include<map> 9 #include<set> 10 #include<string> 11 //#include<pair> 12 13 #define N 1005 14 #define M 1000005 15 #define mod 1000000007 16 #define inf 0x3f3f3f3f 17 //#define p 10000007 18 #define mod2 100000000 19 #define ll long long 20 #define LL long long 21 #define maxi(a,b) (a)>(b)? (a) : (b) 22 #define mini(a,b) (a)<(b)? (a) : (b) 23 24 using namespace std; 25 26 ll mul=3628800; 27 ll x,y; 28 ll ans; 29 ll tmi,tma; 30 ll dmi,dma; 31 ll dan; 32 ll num,tot; 33 34 void ini() 35 { 36 ans=0; 37 tmi=y*mul; 38 tma=(y+1)*mul; 39 dmi=tmi/x; 40 dma=tma/x; 41 num=1; 42 dan=mul; 43 tot=mul; 44 } 45 46 47 void solve() 48 { 49 ans=x-1; 50 ll k1,k2; 51 ll te; 52 if(dan>=dma){ 53 ans=-1;return; 54 } 55 for(num=1;num<=x;num++){ 56 te=mul/num; 57 if(dan>=dmi) break; 58 k1=(dmi-dan+te-1)/te; 59 k2=(dma-dan+te-1)/te; 60 // printf(" num=%I64d ans=%I64d dan=%I64d dmi=%I64d dma=%I64d te=%I64d k1=%I64d k2=%I64d\n", 61 // num,ans,dan,dmi,dma,te,k1,k2); 62 if(k1!=k2){ 63 ans+=k1; 64 dan+=k1*mul/num; 65 return; 66 } 67 else{ 68 dan+=(k1-1)*te; 69 ans+=(k1-1); 70 } 71 } 72 } 73 74 void out() 75 { 76 printf("%I64d\n",ans); 77 } 78 79 int main() 80 { 81 //freopen("data.in","r",stdin); 82 //freopen("data.out","w",stdout); 83 //scanf("%d",&T); 84 // for(int ccnt=1;ccnt<=T;ccnt++) 85 // while(T--) 86 while(scanf("%I64d%I64d",&x,&y)!=EOF) 87 { 88 //if(n==0 && k==0 ) break; 89 //printf("Case %d: ",ccnt); 90 ini(); 91 solve(); 92 out(); 93 } 94 95 return 0; 96 }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/njczy2010/p/4028399.html