Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
各位大牛,帮忙看下为什么RE,我已经RE了10几次了。。。。#include <iostream> #include <cmath> #include <string> #include <vector> #include <cstdio> #include <algorithm> using namespace std; //#define debug #ifdef debug #include <fstream> #define INFILE "in.txt" #define OUTFILE "out.txt" ifstream fcin(INFILE); ofstream fcout(OUTFILE); //freopen(INFILE, "r", stdin); //freopen(OUTFILE, "w", stdout); #define cin fcin #define cout fcout #endif #define clr(x) memset(x, 0, sizeof(x)) #define MAXINT 200000000 #define EPS 0.00000001 int point[1000000][3];//0表示点坐标,1表示到该点的最小次数,2表示是否该往上一级 int beg, last; int main() { int i, j, k; int t = MAXINT; cin >> beg >> last; //while(beg != 0 || last != 0){ point[100000][0]= last; i = 100000; if(last < beg) { point[100000][2] = 3; t = beg - last; } while(point[100000][2] != 3) { if(point[i][0] == beg) { if(point[i][1] < t) { t = point[i][1]; } point[i][2] = 3; i--; //cout << t << endl; continue; } if(point[i][0] % 2) { if(point[i][2] % 3 == 0) { //cout << i << " " << point[i][0] << endl; point[i][2] = 1; i++; point[i][0] = point[i - 1][0] - 1; point[i][1] = point[i - 1][1] + 1; } else if(point[i][2] == 1) { //cout << i << " " << point[i][0] << endl; point[i][2]++; i++; point[i][0] = point[i - 1][0] + 1; point[i][1] = point[i - 1][1] + 1; } else { point[i][2]++; i--; } } else { if(point[i][0] / 2 >= beg) { //cout << i << " " << point[i][0] << endl; point[i][0] /= 2; point[i][1]++; } else { //cout << i << " " << point[i][0] << endl; j = beg - point[i][0] / 2 + 1 + point[i][1]; k = point[i][0] - beg + point[i][1]; if(j > k && t > k) t = k; if(k > j && t > j) t = j; point[i][2] = 3; i--; //cout << t << endl; } } } cout << t << endl; //cin >> beg >> last; t = MAXINT; clr(point);} return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator