結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
uenoku
|
| 提出日時 | 2016-11-19 01:22:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,472 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 89,100 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-11-26 10:45:55 |
| 合計ジャッジ時間 | 56,869 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 27 WA * 52 RE * 2 OLE * 17 |
ソースコード
#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<lli, lli>> l;
lli extgcd(lli a, lli b, lli& x, lli& y)
{
lli g = a;
x = 1;
y = 0;
if (b != 0)
g = extgcd(b, a % b, y, x), y -= (a / b) * x;
l.push_back(pair<lli, lli>(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;
lli 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));
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;
}
}
uenoku