結果

問題 No.438 Cwwプログラミング入門
ユーザー vjudge1
提出日時 2025-01-11 13:37:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 36,224 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-11 13:37:14
合計ジャッジ時間 3,607 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 97 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   long long x,y,z; scanf("%lld %lld %lld",&x,&y,&z);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cmath>
using namespace std;
int main() {
  //freopen("code.in","r",stdin);
  //freopen("code.out","w",stdout);
  long long x,y,z; scanf("%lld %lld %lld",&x,&y,&z);
  if(!z) return printf("ccW"),0;
  for(long long a=-10000;a<=10000;a++) {
  	long long b=y?(z-a*x)/y:0;
  	if(a*x+b*y!=z||2*(abs(a)+abs(b))-1>10000) continue;
  	/*if(a>=0&&b>=0) {
  	  printf("c");
  	  for(int i=1;i<a;i++) printf("cC");
  	  for(int i=1;i<=b;i++) printf("wC");
  	  return 0;
	}*/
	if(a>=0&&b<=0) {
	  for(int i=1;i<=-b;i++) printf("w");
	  for(int i=1;i<=a;i++) printf("c");
	  for(int i=1;i<a;i++) printf("C");
	  for(int i=1;i<=-b;i++) printf("W");
	  return 0;
	}
	if(a<=0&&b>=0) {
	  for(int i=1;i<=-a;i++) printf("c");
	  for(int i=1;i<=b;i++) printf("w");
	  for(int i=1;i<b;i++) printf("C");
	  for(int i=1;i<=-a;i++) printf("W");
	  return 0;
	}
  }
  printf("NO");
  return 0;
}
0