結果

問題 No.2174 3 O'clock Easy
ユーザー forest3
提出日時 2025-03-13 16:28:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 160,580 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-13 16:28:08
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)

int main() {
	int N;
	cin >> N;
	ll ans = 0;
	for(int i = 1; i <= N; i++) {
		ll k = i / 3, m = i % 3;
		if(m) {
			k++;
			if(m == 1) ans += 3 * k - 2;
			else {
				ll a = 3 * k - 1;
				ans += a * a;
			}
		}
		else {
			ll a = 3 * k;
			ans += a * a * a;
		}
	}
	cout << ans << endl;
} 
0