Submission #48746056
Source Code Expand
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define int long long
using namespace std;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-10;
const int N=2e5+10;
// struct node{
// friend bool operator<(const node&a,const node&b){
// return ;
// }
// }
//priority_queue<ll,vector<ll>,greater<ll>>pq;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){char F[200];int tmp=x>0?x:-x;if(x<0) putchar('-');int cnt=0;while(tmp>0){F[cnt++]=tmp%10+'0';tmp/=10;}while(cnt>0)putchar(F[--cnt]);}
inline int combination(int n,int k){int sum=0;if (n==k||k==0){return 1;}else{return combination(n-1,k)+combination(n-1,k-1);}}
void solve(){
int a=read(),m=read(),l=read(),r=read();
l-=a,r-=a;
// cout<<l<<' '<<r<<'\n';
if(l<0&&r<0){
cout<<(-l)/m-(-r-1)/m<<'\n';
}else if(r>0&&l>0){
cout<<(r)/m-(l-1)/m<<'\n';
}else {
cout<<(-l)/m+r/m+1<<'\n';
}
//puts(ans>0?"YES":"NO");
//puts(ans>0?"Yes":"No");
}
signed main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
int t=1;
// int t=read();
while(t--){
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Christmas Trees |
| User | EdGrass |
| Language | C++ 20 (gcc 12.2) |
| Score | 250 |
| Code Size | 1400 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3652 KiB |
Compile Error
Main.cpp: In function ‘long long int combination(long long int, long long int)’:
Main.cpp:19:41: warning: unused variable ‘sum’ [-Wunused-variable]
19 | inline int combination(int n,int k){int sum=0;if (n==k||k==0){return 1;}else{return combination(n-1,k)+combination(n-1,k-1);}}
| ^~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 250 / 250 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 03_minmax_00.txt, 03_minmax_01.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3488 KiB |
| 00_sample_01.txt | AC | 1 ms | 3400 KiB |
| 00_sample_02.txt | AC | 1 ms | 3504 KiB |
| 01_random_00.txt | AC | 1 ms | 3516 KiB |
| 01_random_01.txt | AC | 1 ms | 3496 KiB |
| 01_random_02.txt | AC | 1 ms | 3452 KiB |
| 02_random2_00.txt | AC | 1 ms | 3652 KiB |
| 02_random2_01.txt | AC | 1 ms | 3480 KiB |
| 02_random2_02.txt | AC | 1 ms | 3452 KiB |
| 02_random2_03.txt | AC | 1 ms | 3460 KiB |
| 02_random2_04.txt | AC | 1 ms | 3460 KiB |
| 02_random2_05.txt | AC | 1 ms | 3364 KiB |
| 02_random2_06.txt | AC | 1 ms | 3556 KiB |
| 02_random2_07.txt | AC | 1 ms | 3496 KiB |
| 02_random2_08.txt | AC | 1 ms | 3572 KiB |
| 03_minmax_00.txt | AC | 1 ms | 3428 KiB |
| 03_minmax_01.txt | AC | 1 ms | 3460 KiB |
| 04_handmade_00.txt | AC | 1 ms | 3572 KiB |
| 04_handmade_01.txt | AC | 1 ms | 3460 KiB |
| 04_handmade_02.txt | AC | 1 ms | 3488 KiB |