1 solutions
-
0
C :
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include<math.h> //x空瓶子 int f(int x){ if(x<2) return 0; else return f(x/2+x%2)+x/2; } int main(){ int n,m; scanf("%d%d",&n,&m); printf("%d",f(m/n)+m/n); return 0; }
C++ :
#include <bits/stdc++.h> using namespace std; //x个瓶子换饮料 int fun(int x){ if(x >= 2){ return x / 2 + fun(x / 2 + x % 2); } else{ return 0; } } int main(){ int n,m; cin>>n>>m; //直接买到的数量+换的数量 cout<<m/n+fun(m/n)<<endl; return 0; }
- 1
Information
- ID
- 10685
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By