結果
問題 |
No.604 誕生日のお小遣い
|
ユーザー |
![]() |
提出日時 | 2017-12-08 15:38:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,096 bytes |
コンパイル時間 | 572 ms |
コンパイル使用メモリ | 66,552 KB |
最終ジャッジ日時 | 2025-01-05 04:59:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 TLE * 2 |
other | AC * 4 TLE * 16 MLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int BinarySearch(Yuki, long long int, long long int, long long int)’: main.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type] 40 | } | ^ main.cpp: In function ‘int main()’: main.cpp:46:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%lld %lld %lld", &a_num, &b_get, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream> class Yuki { public: long long int old; long long int sum; long long int old_start; }; int BinarySearch(Yuki yuki, long long int a_num, long long int b_get, long long int c) { long long int nget = yuki.old_start / a_num; yuki.sum = b_get * nget + (yuki.old_start - nget); long long int tmp_p; if((yuki.old_start+1)%a_num == 0){ tmp_p = yuki.sum + b_get; } else { tmp_p = yuki.sum + 1; } if(yuki.sum < c){ if(tmp_p >= c){ yuki.old = yuki.old_start + 1; printf("%lld\n", yuki.old); return 0; } yuki.old_start = (c + yuki.old_start) / 2; BinarySearch(yuki, a_num, b_get, c); } else if(yuki.sum > c){ yuki.old_start = yuki.old_start / 2; BinarySearch(yuki, a_num, b_get, c); } else { printf("%lld\n", yuki.old); return 0; } } int main(void) { long long int a_num, b_get, c; scanf("%lld %lld %lld", &a_num, &b_get, &c); Yuki yuki; yuki.sum=0; // yuki.old = 1; yuki.old_start = c / 2; BinarySearch(yuki, a_num, b_get, c); //printf("%lld\n", yuki.old); return 0; }