Submission #20150067
Source Code Expand
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<bitset>
#include<deque>
#include<cstdlib>
#include<set>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
ll read()
{
ll x=0,f=1;
char c=getchar();
while(c>'9'||c<'0')
{
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=x*10+c-'0';
c=getchar();
}
return f*x;
}
ll B,C;
ll work1(ll C){
ll ans=0;
if(C/2>=B) ans+=abs(B)*2-1;
else
{
ans+=C/2*2-!(C&1);
}
return ans;
}
ll work2(ll C)
{
return C/2*2-!(C&1);
}
int main()
{
B=read(),C=read();
if(C==1) cout<<2-(B==0)<<'\n';
else if(!B)
{
cout<<1+C/2*2-!(C&1)<<'\n';
}
else
{
if(B<0) cout<<work1(C-1)+work2(C)+2<<'\n';
else cout<<work1(C)+work2(C-1)+2<<'\n';
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - -- - B |
| User | MTS_zx |
| Language | C++ (Clang 10.0.0) |
| Score | 400 |
| Code Size | 909 Byte |
| Status | AC |
| Exec Time | 13 ms |
| Memory | 3116 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample.txt, sample_2.txt, sample_3.txt, sample_4.txt |
| All | 0_1.txt, 0_1000000000000000000.txt, 1000000000000000000_1.txt, 1000000000000000000_1000000000000000000.txt, 1312150450968415_354979173822804784.txt, 252509054433933443_74859962623690081.txt, 335408917861648769_779547116602436426.txt, 489647926824927166_979295853649854331.txt, 489647926824927166_979295853649854332.txt, 489647926824927166_979295853649854333.txt, 522842184971407772_585335723211047202.txt, 645762258982631929_269587449430302156.txt, 84324828731963978_148049062628894325.txt, 891351282707723854_349993004923078537.txt, sample.txt, sample_2.txt, sample_3.txt, sample_4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_1.txt | AC | 13 ms | 3072 KiB |
| 0_1000000000000000000.txt | AC | 1 ms | 2992 KiB |
| 1000000000000000000_1.txt | AC | 2 ms | 2916 KiB |
| 1000000000000000000_1000000000000000000.txt | AC | 2 ms | 2964 KiB |
| 1312150450968415_354979173822804784.txt | AC | 1 ms | 3044 KiB |
| 252509054433933443_74859962623690081.txt | AC | 2 ms | 2928 KiB |
| 335408917861648769_779547116602436426.txt | AC | 3 ms | 2936 KiB |
| 489647926824927166_979295853649854331.txt | AC | 4 ms | 3116 KiB |
| 489647926824927166_979295853649854332.txt | AC | 2 ms | 3052 KiB |
| 489647926824927166_979295853649854333.txt | AC | 5 ms | 3056 KiB |
| 522842184971407772_585335723211047202.txt | AC | 2 ms | 3064 KiB |
| 645762258982631929_269587449430302156.txt | AC | 2 ms | 2956 KiB |
| 84324828731963978_148049062628894325.txt | AC | 2 ms | 3060 KiB |
| 891351282707723854_349993004923078537.txt | AC | 2 ms | 2996 KiB |
| sample.txt | AC | 2 ms | 3056 KiB |
| sample_2.txt | AC | 2 ms | 2892 KiB |
| sample_3.txt | AC | 1 ms | 2920 KiB |
| sample_4.txt | AC | 2 ms | 2964 KiB |