結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-02-16 06:33:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 909 bytes |
| コンパイル時間 | 917 ms |
| コンパイル使用メモリ | 67,560 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:05 |
| 合計ジャッジ時間 | 1,270 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:9: error: ‘function’ was not declared in this scope
34 | function<int(const Rational&, const Rational&)> Stern_Brocot_Tree = [&](const Rational &low, const Rational &high) -> int{
| ^~~~~~~~
main.cpp:11:1: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
10 | #include <set>
+++ |+#include <functional>
11 | using namespace std;
main.cpp:34:54: error: expression list treated as compound expression in functional cast [-fpermissive]
34 | function<int(const Rational&, const Rational&)> Stern_Brocot_Tree = [&](const Rational &low, const Rational &high) -> int{
| ^
main.cpp:34:18: error: expected primary-expression before ‘int’
34 | function<int(const Rational&, const Rational&)> Stern_Brocot_Tree = [&](const Rational &low, const Rational &high) -> int{
| ^~~
main.cpp:48:19: error: ‘Stern_Brocot_Tree’ was not declared in this scope
48 | int ans = Stern_Brocot_Tree(Rational(0,1), Rational(1,1));
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
#define MOD 1000003
// n / d
struct Rational{
int n;
int d;
Rational(int n_, int d_) : n(n_), d(d_){
}
Rational operator+(const Rational &x) const{
return Rational(this->n + x.n, this->d + x.d);
}
};
int main(){
long long L;
cin >> L;
function<int(const Rational&, const Rational&)> Stern_Brocot_Tree = [&](const Rational &low, const Rational &high) -> int{
Rational med = low+high;
int n = med.n;
int m = med.d;
if( 8LL*m*(n+m) > L ) return 0;
int ret = ((m-n)%2==0)?0:1;
ret += Stern_Brocot_Tree(low, med);
ret += Stern_Brocot_Tree(med, high);
return ret;
};
int ans = Stern_Brocot_Tree(Rational(0,1), Rational(1,1));
ans %= MOD;
cout << ans << endl;
return 0;
}
koyumeishi