QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189272 | #3716. Simple Arithmetic | Cidoai# | AC ✓ | 2ms | 1600kb | C++20 | 815b | 2023-09-27 07:46:15 | 2023-09-27 07:46:17 |
Judging History
answer
#include<cstdio>
typedef long long ll;
typedef __int128 Ln;
inline ll read(){
ll x=0;
int f=0,ch=0;
while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
return f?-x:x;
}
inline void write(Ln x,char end='\n'){
if(x==0){
putchar('0');
putchar(end);
return;
}
if(x<0) putchar('-'),x=-x;
int ch[70]={0},cnt=0;
while(x){
ch[cnt++]=(int)(x%10);
x/=10;
}
while(cnt--) putchar(ch[cnt]+48);
putchar(end);
}
int main(){
ll x,y;
while(~scanf("%lld%lld",&x,&y)){
Ln a=x,b=y;
Ln ans=a/b;
if(a>=0){
if(b>0){
if(ans*b>a) ans--;
}
else{
if(ans*b<a) ans--;
}
}
else{
if(b>0){
if(ans*b>a) ans--;
}
else{
if(ans*b<a) ans--;
}
}
write(ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 1600kb
input:
3 2 3 -2 -9223372036854775808 1 -9223372036854775808 -1 9223372036854775807 1 9223372036854775807 -1 -9223372036854775808 2 -9223372036854775808 -2 9223372036854775807 2 9223372036854775807 -2 -2076046199237518199 8895005889588087898 -3939164353449408 -1673591601308294572 236330652387008908 24746725...
output:
1 -2 -9223372036854775808 9223372036854775808 9223372036854775807 -9223372036854775807 -4611686018427387904 4611686018427387904 4611686018427387903 -4611686018427387904 -1 0 0 -1 -1 2 -2 -1 0 -2 1 0 0 -2 1 0 -37 0 0 3 -1 8 -1 8 -1 -1 -2 0 0 2 8 -1 0 -1 -2 -1 -5 -7 -1 -2 -3 -1 1 0 -11 -1 2 -1 11 8 0 ...
result:
ok 9875 tokens