結果

問題 No.78 クジ付きアイスバー
ユーザー koyumeishikoyumeishi
提出日時 2014-11-26 02:01:41
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 892 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 23,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 04:58:30
合計ジャッジ時間 5,669 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 RE -
testcase_04 AC 1 ms
5,376 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d %d\n%s", &n, &k, s);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

//愚直解で通るのかしら

#include "stdio.h"

int main(){
	int n;
	int k;
	int v[100];
	char s[100];
	
	int m;
	int block;
	int rem;
	int x;
	int y;
	
	int ans = 0;
	int p = 0;
	int i,j;
	int q = 0;
	
	scanf("%d %d\n%s", &n, &k, s);
	
	m = (100/n) * n;
	block = k/m;
	rem = k%m;
	x = (m/4) * m;
	y = m%4;
	
	for(i=0; i<m; i++){
		v[i] = (s[(i%n)] - '0');
	}


	q = 4*x;
	for(i=0; i<block; ++i){
		for(j=0; j<x; j+=4){
			if(p == 0) ++ans;
			else --p;
			p += v[j];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+1];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+2];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+3];
		}
		for(j=0; j<y; j++){
			if(p == 0) ++ans;
			else --p;
			p += v[q+j];
		}
	}
	for(i=0; i<rem; ++i){
		if(p == 0) ++ans;
		else --p;
		p += v[i];
	}

	printf("%d\n", ans);
	return 0;
}
0