GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Samples/Problem/2-2b.cpp at main · cpp-make/Samples Expand file tree/ Copy path2-2b.cppMore file actions 38 lines (33 loc) · 936 Bytes / Copy path2-2b.cppFile metadata and controls38 lines (33 loc) · 936 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include <iostream> int main() { // 入力を行う int N; std::cin >> N; // 二分探索の初期値 (答えは 1 以上 10 億以下) int Left = 1; int Right = 1000000000; // 二分探索を行う while (true) { // 答えが 1 通りに絞られた場合、答えを出力 if (Left == Right) { std::cout << Left << '\n'; break; } // そうでない場合、真ん中での式の値を確認 int Mid = (Left + Right) / 2; int Value = (Mid / 5) + (Mid / 7) + (Mid / 10); // もし Value が N 以上ならば、答えは Mid 以下 if (Value >= N) { Right = Mid; // 答えの上限を Mid にする } // そうでないならば、答えは Mid+1 以上 else { Left = Mid + 1; // 答えの下限を Mid + 1 にする } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |