結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-11-19 01:20:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,533 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 90,320 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-26 10:36:07 |
合計ジャッジ時間 | 11,103 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 24 WA * 72 RE * 2 |
ソースコード
#include "math.h" #include <algorithm> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define ifor(i, a, b) for (int i = (a); i < (b); i++) #define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; typedef long double ld; typedef long long int lli; typedef long long int ll; typedef complex<double> P; const double eps = 1e-11; int vex[4] = {1, 0, -1, 0}; int vey[4] = {0, 1, 0, -1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD = 1000000007; #define MAX 200005 #define inf MAX lli gcd(lli a, lli b) { return b > a ? gcd(b, a) : (b == 0 ? a : gcd(b, a % b)); } vector<pair<int, int>> l; lli extgcd(lli a, lli b, lli& x, lli& y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; l.push_back(pair<int, int>(a, b)); return g; } int main() { lli x, y, z, tx = 0, ty = 0; cin >> x >> y >> z; //cout << extgcd(x, y, tx, ty) << endl; z % extgcd(x, y, tx, ty); //cerr << tx << ' ' << ty << endl; int m = MOD; rep(i, l.size()) { if (abs(l[i].first) + abs(l[i].second) < m) { m = abs(l[i].first) + abs(l[i].second); tx = l[i].first; ty = l[i].second; } } if (z % gcd(x, y) != 0) { cout << "NO" << endl; } else { tx *= (z / gcd(x, y)); ty *= (z / gcd(x, y)); cout << tx << ' ' << ty << endl; return 0; if (tx > 0) { cout << "c"; rep(i, tx - 1) { cout << "cC"; } } else if (tx == 0) { cout << "ccW"; } else { tx = -tx; rep(i, tx + 2) { cout << "c"; } rep(i, tx + 1) { cout << "W"; } } if (ty > 0) { cout << "w"; rep(i, ty - 1) { cout << "wC"; } } else if (ty == 0) { cout << "wwW"; } else { ty = -ty; rep(i, ty + 2) { cout << "w"; } rep(i, ty + 1) { cout << "W"; } } cout << "C" << endl; } }