結果

問題 No.438 Cwwプログラミング入門
ユーザー uenoku
提出日時 2016-11-19 01:08:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
OLE  
実行時間 -
コード長 2,137 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 86,576 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2024-11-26 10:35:41
合計ジャッジ時間 136,397 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44 WA * 18 RE * 2 OLE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#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));
}

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;
    return g;
}
int main()
{
    lli x, y, z, tx = 0, ty = 0;
    cin >> x >> y >> z;
    //cout << extgcd(x, y, tx, ty) << endl;
    if (z % extgcd(x, y, tx, ty) != 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;
    }
}
0