結果
問題 |
No.299 蟻本が読めない
|
ユーザー |
![]() |
提出日時 | 2025-05-14 13:07:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,460 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 67,844 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-14 13:09:22 |
合計ジャッジ時間 | 870 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
#include <iostream> // Required for input/output operations (cin, cout) int main() { // Declare a variable 'n' of type long long to store the input version number. // We use long long because N can be as large as 10^10, which exceeds the capacity of a standard 32-bit integer. long long n; // Read the input value for N from the standard input. std::cin >> n; // Calculate the number of pages for the N-th version using the arithmetic sequence formula. // The formula for the n-th term of an arithmetic sequence is: a_n = a_1 + (n - 1) * d // Here: // a_1 (pages of version 1) = 316 // d (common difference) = 368 - 316 = 52 // n = the input version number N // // We use 'LL' suffix for the integer literals (316, 1, 52) to ensure that // the intermediate calculations are performed using 64-bit arithmetic (long long), // preventing potential overflow issues, especially when N is large. long long pages = 316LL + (n - 1LL) * 52LL; // Alternatively, the formula can be simplified: // pages = 316 + 52*n - 52 // pages = 52*n + 264 // long long pages = 52LL * n + 264LL; // This would also work correctly. // Print the calculated number of pages to the standard output. std::cout << pages; // Print a newline character as required by the problem statement. std::cout << std::endl; // Indicate successful program execution by returning 0. return 0; }