結果
| 問題 | No.299 蟻本が読めない |
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 13:14:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 2,487 bytes |
| 記録 | |
| コンパイル時間 | 645 ms |
| コンパイル使用メモリ | 65,408 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-05-14 13:15:54 |
| 合計ジャッジ時間 | 951 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <iostream> // Include the iostream library for input and output operations
int main() {
// Declare a variable 'n' of type long long.
// 'long long' is a 64-bit integer type in C++, necessary because the input N
// can be as large as 10^10, which exceeds the capacity of a standard 32-bit integer (int).
long long n;
// Read the integer value N from standard input (usually the console).
std::cin >> n;
// Calculate the predicted number of pages for the N-th edition.
// The problem states that the first edition (N=1) has 316 pages and the second edition (N=2) has 368 pages.
// It hypothesizes that the page count follows an arithmetic progression.
// An arithmetic progression is a sequence where the difference between consecutive terms is constant.
// Let P(N) be the number of pages in the N-th edition.
// The first term is P(1) = 316.
// The second term is P(2) = 368.
// The common difference 'd' is the difference between consecutive terms:
// d = P(2) - P(1) = 368 - 316 = 52.
//
// The formula for the N-th term of an arithmetic progression is:
// P(N) = P(1) + (N - 1) * d
// Substituting the values we have:
// P(N) = 316 + (N - 1) * 52
//
// This formula can be simplified algebraically:
// P(N) = 316 + 52 * N - 52 * 1
// P(N) = 316 + 52*N - 52
// P(N) = 52*N + (316 - 52)
// P(N) = 52*N + 264
//
// We use this simplified formula for the calculation.
// The literals 52LL and 264LL use the 'LL' suffix to specify that they are of type long long.
// This ensures that all calculations, especially the multiplication 52LL * n, are performed
// using 64-bit arithmetic. This is important to prevent potential integer overflow issues,
// as the result of 52 * N can exceed the maximum value of a 32-bit integer even if N itself fits.
long long result = 52LL * n + 264LL;
// Print the calculated result to standard output (usually the console).
std::cout << result;
// Print a newline character after the result. This is required by the problem statement
// ("最後に改行してください。" - Please add a newline at the end.) and is standard practice
// in competitive programming to ensure the output format is correct.
std::cout << std::endl;
// Return 0 from the main function. In C++, returning 0 from main indicates that
// the program executed successfully.
return 0;
}
qwewe