結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
hirokazu1020
|
| 提出日時 | 2016-10-29 00:27:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,850 bytes |
| コンパイル時間 | 1,037 ms |
| コンパイル使用メモリ | 97,280 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 22:03:38 |
| 合計ジャッジ時間 | 7,153 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 98 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
long long run(int x,int y,string s) {
long long st[5001];
int p = 0;
for (char c : s) {
if (c == 'c') {
st[p++] = x;
}
else if (c == 'w') {
st[p++] = y;
}
else if (c == 'C') {
st[p - 2] = st[p - 1] + st[p - 2];
p --;
}
else {
st[p - 2] = st[p - 1] - st[p - 2];
p --;
}
}
return st[0];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x, y, z;
cin >> x >> y >> z;
for (int i = -5000; i <= 5000;i++) {
for (int j = -5000 + abs(i); j <= 5000 - abs(i); j++) {
if (x*i + y*j == z) {
int n = (abs(i) + abs(j)) * 2 - 1;
if (n > 10000)continue;
string num, op;
if (i > 0) {
num+= 'c';
rep(_, i - 1) {
num += 'c';
op += 'C';
}
if (j > 0) {
rep(_, j) {
num += 'w';
op += 'C';
}
}
else {
rep(_, -j) {
num += 'w';
op += 'W';
}
}
}
else if (j > 0) {
num += 'w';
rep(_, j - 1) {
num += 'w';
op += 'C';
}
rep(_, -i) {
num += 'c';
op += 'W';
}
}
else {
num += "cc";
op += 'W';
}
reverse(all(num));
//cout << run(x, y, num + op)<<endl;
cout << num << op << endl;
return 0;
}
}
}
cout << "mourennaihasimasenn" << endl;
return 0;
}
hirokazu1020