Submission #33621735
Source Code Expand
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
//#define mp make_pair
//#define OO(x) fixed<<setprecision(x)
using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int read(){
char ch=getchar(); int w=1,c=0;
for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
return w*c;
}
int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
LL n,A,B; cin>>n>>A>>B;
if (A<=B){
cout<<max(0ll,n-A+1)<<"\n";
return 0;
}
LL d=n/A,p=d*A;
// cerr<<p<<" "<<n<<" "<<d*B<<" "<<n%A<<" ???\n";
LL ans=d*B+min(p+B-1,n)-p+1;
cout<<max(0ll,ans-B)<<"\n";
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
Submission Info
| Submission Time | |
|---|---|
| Task | B - AB Game |
| User | yangziheng |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 1081 Byte |
| Status | AC |
| Exec Time | 6 ms |
| Memory | 3612 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 6 ms | 3504 KiB |
| 00_sample_02.txt | AC | 4 ms | 3372 KiB |
| 01_random_01.txt | AC | 2 ms | 3576 KiB |
| 01_random_02.txt | AC | 4 ms | 3504 KiB |
| 01_random_03.txt | AC | 2 ms | 3576 KiB |
| 01_random_04.txt | AC | 2 ms | 3612 KiB |
| 01_random_05.txt | AC | 2 ms | 3604 KiB |
| 01_random_06.txt | AC | 2 ms | 3372 KiB |
| 01_random_07.txt | AC | 2 ms | 3508 KiB |
| 01_random_08.txt | AC | 2 ms | 3428 KiB |
| 01_random_09.txt | AC | 2 ms | 3504 KiB |
| 01_random_10.txt | AC | 2 ms | 3532 KiB |
| 02_handmade_01.txt | AC | 2 ms | 3504 KiB |
| 02_handmade_02.txt | AC | 3 ms | 3424 KiB |
| 02_handmade_03.txt | AC | 2 ms | 3384 KiB |
| 02_handmade_04.txt | AC | 2 ms | 3388 KiB |
| 02_handmade_05.txt | AC | 3 ms | 3600 KiB |
| 02_handmade_06.txt | AC | 2 ms | 3612 KiB |
| 02_handmade_07.txt | AC | 2 ms | 3600 KiB |
| 02_handmade_08.txt | AC | 2 ms | 3576 KiB |
| 02_handmade_09.txt | AC | 3 ms | 3428 KiB |
| 02_handmade_10.txt | AC | 2 ms | 3572 KiB |