| ||||||||||
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:加减乘除都不用就把这题AC了!In Reply To:加减乘除都不用就把这题AC了! Posted by:nan5515522 at 2014-05-26 21:06:14 这题忒难了,总算想到二分法水过了!贴代码纪念一下! #include <iostream> #include <algorithm> #include <cstdio> #include<queue> #include<vector> using namespace std; int bin(int a, int b) { int start = 0, end = 100, middle; if(start - a -b == 0) return start; while(1) { middle = (start + end) / 2; if(middle - a - b == 0) return middle; else if(middle - a - b > 0) end = middle; else start = middle; } return -1; } int main() { int a, b; cin >> a >> b; cout << bin(a, b) << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator