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 7
3 6
4 9
Sample Output
Case #1: 3
Case #2: 1
Case #3: 2
Source
分析:
然后分别去判断即可!详细请看代码。
下面给出AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,m;
ll p=;
while(scanf("%lld%lld",&n,&m)!=EOF)
{
printf("Case #%lld: ",p++);
if(m<=n)
{
printf("%lld\n",m);
continue;
}
ll c=m-n;
if(c%(*(n-))==)
{
printf("%lld\n",n);
continue;
}
if(c%(*(n-))<=n-)
printf("%lld\n",c%(*(n-)));
else
{
ll k=c%(*(n-))%(n-);
printf("%lld\n",k);
}
}
return ;
}