KazaQ's Socks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 338 Accepted Submission(s): 212
Sample Input
3 73 64 9
Sample Output
Case #1: 3Case #2: 1Case #3: 2
Source
题目链接:
分析:
然后分别去判断即可!详细请看代码。
下面给出AC代码:
1 #include2 using namespace std; 3 typedef long long ll; 4 int main() 5 { 6 ll n,m; 7 ll p=1; 8 while(scanf("%lld%lld",&n,&m)!=EOF) 9 {10 printf("Case #%lld: ",p++);11 if(m<=n)12 {13 printf("%lld\n",m);14 continue;15 }16 ll c=m-n;17 if(c%(2*(n-1))==0)18 {19 printf("%lld\n",n);20 continue;21 }22 if(c%(2*(n-1))<=n-1)23 printf("%lld\n",c%(2*(n-1)));24 else25 {26 ll k=c%(2*(n-1))%(n-1);27 printf("%lld\n",k);28 }29 }30 return 0;31 }