Submission #809376
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int main()
{
ll n,a,sum=0,cnt=0;
cin>>n>>a;
ll p=min(a,n-a),q=max(a,n-a);
sum+=q;
bool flag=false;
while(q%p!=0)
{
cnt++;
if(cnt<=1)sum+=2*p*(q/p);
else sum+=2*p*(q/p)-p;
ll a=q%p,b=p;
p=min(a,b),q=max(a,b);
sum+=q;
flag=true;
}
sum+=2*p*(q/p);
if(flag)sum-=p;
cout<<sum<<endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Mysterious Light |
| User | kkrtjnj3829 |
| Language | C++14 (GCC 5.4.1) |
| Score | 500 |
| Code Size | 533 Byte |
| Status | AC |
| Exec Time | 6 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | Subtask | All | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | 200 / 200 | ||||||
| Status |
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt |
| Subtask | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
| All | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 4 ms | 256 KiB |
| 01-02.txt | AC | 4 ms | 256 KiB |
| 01-03.txt | AC | 4 ms | 256 KiB |
| 01-04.txt | AC | 4 ms | 256 KiB |
| 01-05.txt | AC | 6 ms | 256 KiB |
| 01-06.txt | AC | 5 ms | 256 KiB |
| 01-07.txt | AC | 4 ms | 256 KiB |
| 01-08.txt | AC | 4 ms | 256 KiB |
| 01-09.txt | AC | 6 ms | 256 KiB |
| 02-01.txt | AC | 6 ms | 256 KiB |
| 02-02.txt | AC | 4 ms | 256 KiB |
| 02-03.txt | AC | 4 ms | 256 KiB |
| 02-04.txt | AC | 4 ms | 256 KiB |
| 02-05.txt | AC | 4 ms | 256 KiB |
| 02-06.txt | AC | 4 ms | 256 KiB |
| 02-07.txt | AC | 4 ms | 256 KiB |
| 02-08.txt | AC | 4 ms | 256 KiB |
| 02-09.txt | AC | 4 ms | 256 KiB |
| sample-01.txt | AC | 4 ms | 256 KiB |