A. Vasya and Socks

题意:起初给你n双袜子,每天穿一双,每到m天会多一双新的,求有多少天有袜子穿

题解:模拟即可

代码:

 1 #include<cstdio>
 2 #include<cstdlib>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<iostream>
 7 #include<vector>
 8 #include<map>
 9 #include<set>
10 #include<queue>
11 #define inf 1000000000
12 #define maxn 500+100
13 #define maxm 500+100
14 #define eps 1e-10
15 #define ll long long
16 using namespace std;
17 inline int read()
18 {
19     int x=0,f=1;char ch=getchar();
20     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
21     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
22     return x*f;
23 }
24 
25 int main()
26 {
27     int n=read(),m=read(),sum=n,i=0;
28     while(1)
29     {
30         sum--;
31         i++;if(i%m==0)sum++;
32         if(!sum)break;    
33     }
34     cout<<i<<endl;
35     return 0;
36 }
37     
View Code

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-08-12
  • 2021-04-24
  • 2021-12-04
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2021-08-06
  • 2021-07-23
相关资源
相似解决方案