ぐぬぬ。codeforces
codeforces #18
Problem B
桜花たんから教えてもらってA通りましたよ!ありがとう!
http://d.hatena.ne.jp/rofi/20100618/1276818705
でもBが通らない。なぜだ。
問題読んで再帰を使いたくなったので
#include <iostream> using namespace std; struct Info { int n; int d; int m; int l; Info() :n(0),d(0),m(0),l(0) {} }; int step(int s, const Info& info) { const int cur_pos = s * info.d; if( cur_pos > (info.n-1) * info.m + info.l ) { return s; } //out of last platform if( (cur_pos % info.m) > info.l ) { return s; } //fall down info gap between platforms return step(s+1, info); } Info GetInfo() { Info info; cin >> info.n >> info.d >> info.m >> info.l; info.n -= 1; //n as maximum index of platforms return info; } int main() { const Info info = GetInfo(); const int adv = step(0, info); cout << adv * info.d; }
こんな感じのを書いたのだけど、、、何がおかしいんだろう・・・