結果
| 問題 |
No.415 ぴょん
|
| ユーザー |
nanophoto12
|
| 提出日時 | 2016-09-22 21:16:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,709 bytes |
| コンパイル時間 | 670 ms |
| コンパイル使用メモリ | 89,544 KB |
| 実行使用メモリ | 13,636 KB |
| 最終ジャッジ日時 | 2024-11-17 13:11:44 |
| 合計ジャッジ時間 | 11,583 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 TLE * 5 |
ソースコード
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
using namespace std;
#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
std::fill( (T*)array, (T*)(array+N), val );
}
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) { }
bool unionSet(int x, int y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
};
const ll mod = (ll)(1e9+7);
struct SimpleHash {
size_t operator()(const std::pair<ll, ll>& p) const {
return p.first * mod + p.second;
}
};
int main()
{
ll n, d;
cin >> n >> d;
ll front = 0;
ll c = 0;
if(d > n)
{
d = d % n;
}
if(d == 0)
{
cout << 0 << endl;
return 0;
}
if(n == d)
{
cout << 0 << endl;
return 0;
}
while(true)
{
ll rest = (n-front) % d;
c += (n-front) / d;
if(rest == 0)
{
break;
}
front = - rest;
}
cout << c-1 << endl;
return 0;
}
nanophoto12