結果

問題 No.305 鍵(2)
ユーザー hotpepsihotpepsi
提出日時 2015-11-29 23:25:54
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 578 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 60,980 KB
実行使用メモリ 35,532 KB
最終ジャッジ日時 2023-09-23 22:12:40
合計ジャッジ時間 7,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:21:43: warning: integer overflow in expression of type ‘int’ results in ‘-2147483648’ [-Woverflow]
    w[i] = '0' + (rand() * 10) / (RAND_MAX + 1);
                                           ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

int getres(const char *w) {
	printf("%s\n", w);
	fflush(stdout);
	char buff[1024];
	fgets(buff, 1024, stdin);
	return atoi(buff);
}

int main(int argc, char *argv[])
{
	char w[16] = {};
	while (true) {
		for (int i = 0; i < 10; ++i) {
			w[i] = '0' + (rand() * 10) / (RAND_MAX + 1);
		}
		if (getres(w) == 0) {
			break;
		}
	}
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			w[i] = '0' + j;
			if (getres(w) == i + 1) {
				break;
			}
		}
	}
	return 0;
}
0