結果
問題 |
No.415 ぴょん
|
ユーザー |
![]() |
提出日時 | 2018-08-22 18:29:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 1,153 ms |
コンパイル使用メモリ | 96,192 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-24 12:48:22 |
合計ジャッジ時間 | 2,211 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 17 |
ソースコード
#include <stdio.h> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <functional> #include <map> #include <iomanip> #include <math.h> #include <stack> #include <queue> #include <bitset> #include <cstdlib> #include <tuple> #include <cctype> #include <ctype.h> using namespace std; int main() { int i, j, k; long n, d; cin >> n >> d; long jyo = 0, iti = 0, tugi = 0, sum = 0, cnt = 0; vector<long>amari; amari.push_back(1); cnt++; if (n - 1 == d) { cout << n - 1 << endl; getchar(); getchar(); return 0; } if (n == d) { cout << 0 << endl; getchar(); getchar(); return 0; } if (n%d == 0) { cout << n / d - 1 << endl; getchar(); getchar(); return 0; } else { cout << n / (n + 1 - (((n - 1) / d)*d + 1)) - 1 << endl; getchar(); getchar(); return 0; } while (true) { jyo = (n - amari[cnt-1]) / d; sum += jyo; //amari.push_back() iti = jyo * d + amari[cnt -1]; tugi = d - (n - iti); bool flag = false; for (i = 0; i < cnt; i++) { if (amari[i] == tugi) { flag = true; break; } } if (flag == false) { amari.push_back(tugi); cnt++; sum++; } else { break; } } cout << sum << endl; getchar(); getchar(); return 0; }