結果

問題 No.438 Cwwプログラミング入門
ユーザー onkohdondoonkohdondo
提出日時 2016-10-28 23:40:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 8,787 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 163,616 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 20:31:03
合計ジャッジ時間 13,803 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,248 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,248 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,248 KB
testcase_19 AC 1 ms
5,248 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
5,248 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
5,248 KB
testcase_28 RE -
testcase_29 WA -
testcase_30 AC 1 ms
5,248 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
5,248 KB
testcase_39 WA -
testcase_40 AC 2 ms
5,248 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 1 ms
5,248 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 1 ms
5,248 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
5,248 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 1 ms
5,248 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 1 ms
5,248 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 1 ms
5,248 KB
testcase_66 WA -
testcase_67 AC 2 ms
5,248 KB
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 AC 2 ms
5,248 KB
testcase_80 WA -
testcase_81 AC 2 ms
5,248 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 2 ms
5,248 KB
testcase_85 AC 2 ms
5,248 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 RE -
testcase_89 RE -
testcase_90 RE -
testcase_91 RE -
testcase_92 RE -
testcase_93 RE -
testcase_94 RE -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 AC 1 ms
5,248 KB
testcase_99 WA -
testcase_100 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 | #define SCANF_LL(a) scanf("%lld", &(a));
      |                     ~~~~~^~~~~~~~~~~~~~
main.cpp:12:9: note: in expansion of macro ‘SCANF_LL’
   12 |         MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)
      |         ^~~~~
main.cpp:5:69: note: in expansion of macro ‘EXPAND_03’
    5 | #define GET_MACRO_09(A0, A1, A2, A3, A4, A5, A6, A7, A8, NAME, ...) NAME
      |                                                                     ^~~~
main.cpp:40:28: note: in expansion of macro ‘EXPAND_ARG_0’
   40 | #define EXPAND(MACRO, ...) EXPAND_ARG_0(MACRO, __VA_ARGS__)
      |                            ^~~~~~~~~~~~
main.cpp:58:18: note: in expansion of macro ‘EXPAND’
   58 | #define LR(...) {EXPAND(SCANF_LL, __VA_ARGS__)}
      |                  ^~~~~~
main.cpp:316:9: note: in expansion of macro ‘LR’
  316 |         LR(x, y, z);
      |         ^~
main.cpp:56:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 | #define SCANF_LL(a) scanf("%lld", &(a));
      |                     ~~~~~^~~~~~~~~~~~~~
main.cpp:12:34: note: in expansion of macro ‘SCANF_LL’
   12 |         MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)
      |                                  ^~~~~
main.cpp:5:69: note: in expansion of macro ‘EXPAND_03’
    5 | #define GET_MACRO_09(A0, A1, A2, A3, A4, A5, A6, A7, A8, NAME, ...) NAME
      |                                                                     ^~~~
main.cpp:40:28: note: in expansion of macro ‘EXPAND_ARG_0’
   40 | #define EXPAND(MACRO, ...) EXPAND_ARG_0(MACRO, __VA_ARGS__)
      |                            ^~~~~~~~~~~~
main.cpp:58:18: note: in expansion of macro ‘EXP

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// Macro Tools /////////////////////////////////////////////////////////////////
#define GET_MACRO_09(A0, A1, A2, A3, A4, A5, A6, A7, A8, NAME, ...) NAME

#define EXPAND_01(MACRO, A0, ...) \
	MACRO(A0, ##__VA_ARGS__) 
#define EXPAND_02(MACRO, A0, A1, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) 
#define EXPAND_03(MACRO, A0, A1, A2, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__) 
#define EXPAND_04(MACRO, A0, A1, A2, A3, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) 
#define EXPAND_05(MACRO, A0, A1, A2, A3, A4, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) MACRO(A4, ##__VA_ARGS__) 
#define EXPAND_06(MACRO, A0, A1, A2, A3, A4, A5, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) MACRO(A4, ##__VA_ARGS__) MACRO(A5, ##__VA_ARGS__) 
#define EXPAND_07(MACRO, A0, A1, A2, A3, A4, A5, A6, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) MACRO(A4, ##__VA_ARGS__) MACRO(A5, ##__VA_ARGS__)  \
	MACRO(A6, ##__VA_ARGS__) 
#define EXPAND_08(MACRO, A0, A1, A2, A3, A4, A5, A6, A7, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) MACRO(A4, ##__VA_ARGS__) MACRO(A5, ##__VA_ARGS__)  \
	MACRO(A6, ##__VA_ARGS__) MACRO(A7, ##__VA_ARGS__) 
#define EXPAND_09(MACRO, A0, A1, A2, A3, A4, A5, A6, A7, A8, ...) \
	MACRO(A0, ##__VA_ARGS__) MACRO(A1, ##__VA_ARGS__) MACRO(A2, ##__VA_ARGS__)  \
	MACRO(A3, ##__VA_ARGS__) MACRO(A4, ##__VA_ARGS__) MACRO(A5, ##__VA_ARGS__)  \
	MACRO(A6, ##__VA_ARGS__) MACRO(A7, ##__VA_ARGS__) MACRO(A8, ##__VA_ARGS__) 

#define GET_EXPAND(...) GET_MACRO_09(__VA_ARGS__, EXPAND_09, EXPAND_08, \
	EXPAND_07, EXPAND_06, EXPAND_05, EXPAND_04, EXPAND_03, EXPAND_02, EXPAND_01)
#define EXPAND_ARG_0(MACRO, ...) GET_EXPAND(__VA_ARGS__)(MACRO, __VA_ARGS__)
#define EXPAND_ARG_1(MACRO, A0, ...) GET_EXPAND(__VA_ARGS__)(MACRO, __VA_ARGS__, A0)

#define EXPAND(MACRO, ...) EXPAND_ARG_0(MACRO, __VA_ARGS__)

#define Q(x) #x
#define QUOTE(x) Q(x)

// Input ///////////////////////////////////////////////////////////////////////
#define SCANF_INT(a) scanf("%d", &(a));
#define ID(...) int __VA_ARGS__;
#define IR(...) {EXPAND(SCANF_INT, __VA_ARGS__)}
#define I(...) ID(__VA_ARGS__) IR(__VA_ARGS__)

// #define DEFINE_INT_ARRAY(a, n) int a[n];
// #define INT_ITH_ARRAY(a, i) a[i]
// #define IAD(N, ...) EXPAND_ARG_1(DEFINE_INT_ARRAY, N, __VA_ARGS__)
// #define IAR(N, ...) REP(array_reader_i, N){ 

#define SCANF_LL(a) scanf("%lld", &(a));
#define LD(...) ll __VA_ARGS__;
#define LR(...) {EXPAND(SCANF_LL, __VA_ARGS__)}
#define L(...) LD(__VA_ARGS__) LR(__VA_ARGS__)

#define DEFINE_STR(a, n) char a[n];
#define SCANF_STR(a) scanf("%s", a);
#define SD(N, ...) EXPAND_ARG_1(DEFINE_STR, N, __VA_ARGS__)
#define SR(...) EXPAND(SCANF_STR, __VA_ARGS__)
#define S(N, ...) SD(N, __VA_ARGS__) SR(__VA_ARGS__)

// Output //////////////////////////////////////////////////////////////////////
#define LN printf("\n");

#define IP(a, ...) printf("%d", a); 

// Types ///////////////////////////////////////////////////////////////////////
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef list<int> li;
typedef list<ll> lll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

// Loop & Iteration ////////////////////////////////////////////////////////////
#define FORT(t, i, a, b) \
	for(t i = (a), loop_end_##i=(b); i < (loop_end_##i); i++)
#define FORL(i, a, b) FORT(ll, i, a, b)
#define FOR(i, a, b) FORT(int, i, a, b)
#define REPT(t, i, n) FORT(t, i, 0, n)
#define REPL(i, n) FORL(i, 0, n)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(a, a+n)

#define PB push_back
#define MP make_pair
#define itr iterator

// Range ///////////////////////////////////////////////////////////////////////
#define IN(x, a, b) (a<=x && x<b)
#define INC(x, a, b) (a<=x && x<=b)
int dx[8] = { 1, 0, 0,-1, 1, 1,-1,-1};
int dy[8] = { 0,-1, 1, 0,-1, 1,-1, 1};

#define LAR(a, b) ((a)=max((a), (b)))
#define SML(a, b) ((a)=min((a), (b)))

// Debug ///////////////////////////////////////////////////////////////////////
#define println(...) {printf(__VA_ARGS__); printf("\n");}
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define debugln(...) println(__VA_ARGS__)
#else
#define debug(...) {}
#define debugln(...) {}
#endif

// Numbers /////////////////////////////////////////////////////////////////////
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}

#define PRIME_MAX 1000000
bool isprime[PRIME_MAX+5];
void init_prime(){
	fill(isprime, isprime+PRIME_MAX+5, true);
	isprime[0]=isprime[1]=false;
	REP(i, PRIME_MAX+5){
		if(isprime[i]){
			for(int j=i*2; j<PRIME_MAX; j+=i){
				isprime[j]=false;
			}
		}
	}
}

vll factors(ll n){
	vll v;
	REPL(i, PRIME_MAX){
		if(!isprime[i]) continue;
		while(n%i==0){
			v.PB(i);
			n/=i;
		}
	}
	if(n>1){
		v.PB(n);
	}
	return v;
}

// BIT /////////////////////////////////////////////////////////////////////////
template<
	typename T = int
>
class bit{
public:
	T *bit_arr;
	int size;

	bit(int n){
		size = n;
		bit_arr = new T[n];
		fill(bit_arr, bit_arr+n, 0);
	}

	~bit(){
		delete bit_arr;
	}

	T sum(int a){
		T ret = 0;
		while(a){
			ret+=bit_arr[a];
			a-=a&-a;
		}
		return ret;
	}

	T sum(int a, int b){
		return sum(b)-sum(a);
	}

	T get(int a){
		return sum(a, a+1);
	}

	void add(int a, T x){
		a++;
		while(a<size){
			bit_arr[a]+=x;
			a+=a&-a;
		}
	}

	void set(int a, T x){
		add(a, x-get(a));
	}
};
typedef bit<ll> bll;

// RMQ /////////////////////////////////////////////////////////////////////////
template<
	typename T = int,
	class Compare=less<T>
>
class rmq{
public:
	int size;
	Compare comp;
	T *dat;
	T init;
	
	rmq(int n, T init_=INT_MAX){
		init=init_;
		size = 1;
		while(size<n) size*=2;
		dat = new T[2*size-1];
		fill(dat, dat+(2*size-1), init);
	}

	~rmq(){
		delete dat;
	}

	void set(int k, T a){
		k+=size-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=min(dat[k*2+1], dat[k*2+2], comp);
		}
	}

	T get(int a, int b, int k, int l, int r){
		if(r<=a || b<=l) return init;
		if(a<=l && r<=b) return dat[k];
		else{
			T vl = get(a, b, k*2+1, l, (l+r)/2);
			T vr = get(a, b, k*2+2, (l+r)/2, r);
			return min(vl, vr, comp);
		}
	}

	T get(int a, int b){
		return get(a, b, 0, 0, size);
	}
};

// Others //////////////////////////////////////////////////////////////////////
#define MOD 1000000007
#define YES() printf("YES\n")
#define NO() printf("mourennaihasimasenn\n")

////////////////////////////////////////////////////////////////////////////////

pll gt(ll m, ll n){
	if(n==0){
		return MP(1, 0);
	}else{
		ll p = m / n;
		ll q = m % n;
		pll pp = gt(n, q);
		ll a = pp.first;
		ll b = pp.second;
		return MP(b, a-b*p);
	}
}

ll rup(ll a, ll b){
	if(a>=0){
		return (a+b-1)/b;
	}else{
		return -((-a)/b);
	}
}

ll rdn(ll a, ll b){
	if(a>=0){
		return a/b;
	}else{
		return -((-a+b-1)/b);
	}
}

ll a, b;
ll x, y, z;
ll mi = LLONG_MAX;
ll p, q;
void cand(ll a, ll b){
	ll sm = abs(a)+abs(b);
	if(sm<mi){
		mi = sm;
		p = a;
		q = b;
	}
}

void cand(ll k){
	// printf("cand %lld -> %lld, %lld\n", k, a-k*y, b+k*x);
	cand(a-k*y, b+k*x);
}

int main(){
	LR(x, y, z);
	ll g = gcd(x, y);
	if(z%g!=0){
		NO();
		return 0;
	}
	x/=g;
	y/=g;
	z/=g;
	pll pir = gt(x, y);
	ll aa = pir.first, bb = pir.second;
	a = z*aa, b = z*bb;
	printf("%lld*%lld+%lld*%lld=%lld\n", a, x, b, y, z);
	bool swped = false;
	if(x<y){
		swped = true;
		swap(x, y);
		swap(a, b);
	}
	// printf("a=%lld b=%lld\n", a, b);
	// printf("x=%lld y=%lld\n", x, y);
	ll s = rup(-b, x);
	ll t = rdn(a, y);
	if(t-s>=0){
		cand(s-1);
		cand(s);
		cand(t+1);
	}else{
		cand(s-1);
		cand(s);
		cand(t);
	}
	if(mi>5000){
		NO();
		return 0;
	}
	if(swped){
		swap(x, y);
		swap(a, b);
		swap(p, q);
	}
	printf("%lld*%lld+%lld*%lld=%lld\n", p, x, q, y, z);
	if(p<0){
		REP(i, -p) printf("c");
		REP(i, q) printf("w");
		REP(i, q-1) printf("C");
		REP(i, -p) printf("W");
	}else if(q<0){
		REP(i, -q) printf("w");
		REP(i, p) printf("c");
		REP(i, p-1) printf("C");
		REP(i, -q) printf("W");
	}else{
		REP(i, p) printf("c");
		REP(i, q) printf("w");
		REP(i, p+q-1) printf("C");
	}
	LN;
}

0