結果

問題 No.72 そろばん Med
ユーザー Yang33Yang33
提出日時 2018-04-16 14:36:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,954 bytes
コンパイル時間 1,371 ms
コンパイル使用メモリ 163,724 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 10:52:36
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/16  Problem: yukicoder 072  / Link: http://yukicoder.me/problems/no/072  ----- */
/* ------問題------

コンピュータが登場する前、計算する道具といえば「そろばん」だった。
今回は、そのそろばんがテーマの問題である。

一般的なそろばんは、一列だけ見ると、5つ珠があり0〜9まで表すことができる。

これは、1列に串刺し状の上部1つの珠と下部4つの珠に分けて、
下部の動いている珠の数、上部の動いている珠分さらに5を足すという数の表現方法を行う。
つまり上部は、下部の数の繰り上がり数と見ることができる。
参考:Wikipedia
http://ja.wikipedia.org/wiki/%E3%81%9D%E3%82%8D%E3%81%B0%E3%82%93#.E5.B8.83.E6.95.B0.E6.B3.95
(そろばんを知らない方はごめんなさい。。)

このとき、Ursaは特殊なそろばんを思いついた。
一列に使える珠の合計をN個とし、上部と下部に使える珠の数は、合計でN個であれば自由に決めることができるとする。
この時、一列分で表現できる最大の数を求めてください。

ただし、表現方法としてできるのは、それぞれの珠の上げ下げの状態のみで判断するとする。
中途半端に動かすなどできないとし、上部・下部はそれぞれ連続に並んでいる珠なので3つ目が動くなら、1つめ2つ目も連動して動くような機構であるとする。
また、0から最大の数まで一意的な表現ができるとする。

-----問題ここまで----- */
/* -----解説等-----

no61の式を変形すると極地が求められる。

----解説ここまで---- */

LL N;

LL ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	const LL mod = 1000007;
	cin >> N;
	LL x = (N + 1) / 2;
	N %= mod;
	x %= mod;
	ans = -x*x + N*x + N;
	ans = (ans + mod) % mod;
	cout << ans << "\n";

	return 0;
}
0