結果
問題 |
No.689 E869120 and Constructing Array 3
|
ユーザー |
![]() |
提出日時 | 2018-08-23 00:22:52 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 871 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 23:46:39 |
合計ジャッジ時間 | 1,771 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:13:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d",&k); | ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) void run(void){ int k; scanf("%d",&k); if(k==0){ printf("1\n1\n"); return; } const int m=250; int c2,c3,c4,c7; for(c2=1;c2<=m && c2<=k;c2++){ for(c3=1;c3<=c2 && c3<=m-c2 && c3<=k/c2;c3++){ for(c4=0;c4<=c3 && c4<=m-c2-c3 && c4<=(k-c2*c3)/c3;c4++){ for(c7=0;c7<=c4 && c7<=m-c2-c3-c4 && c4*c7<=(k-c2*c3-c3*c4);c7++){ if(c2*c3+c3*c4+c4*c7==k){ printf("%d\n",c2+c3+c4+c7); int i; for(i=0;i<c2;i++) printf("%d ",2); for(i=0;i<c3;i++) printf("%d ",3); for(i=0;i<c4;i++) printf("%d ",4); for(i=0;i<c7;i++) printf("%d ",7); printf("\n"); return; } } } } } } int main(void){ run(); return 0; }