标签:div style code while name exce bsp efi log
所以,我还是太年轻,同一逻辑用Cpp写的,过了,用C写,Output Limit Exceeded。
没过的C
// // main.c // poj2586 // // Created by 韩雪滢 on 11/27/16. // Copyright ? 2016 韩雪滢. All rights reserved. // #include <stdio.h> int surplus=0; int deficit=0; int result = 0; int main() { while(scanf("%d%d",&surplus,&deficit)){ int i=0; while(i*surplus-(5-i)*deficit < 0) i++; i--; result = 2*(i*surplus+(5-i)*deficit); if(i>=2) result += 2*surplus; else result = result + i*surplus - (2-i)*deficit; if(result>0) printf("%d\n",result); else printf("Deficit\n"); } return 0; }
过了的Cpp
// // main.cpp // poj2586Cpp // // Created by 韩雪滢 on 11/27/16. // Copyright ? 2016 韩雪滢. All rights reserved. // #include <iostream> using namespace std; int main(int argc, const char * argv[]) { int s,p; while(cin >> s >> p){ int i=0; while(i*s - (5-i)*p <0) i++; i--; int ans = i*2*s - (5-i)*2*p; if(i>=2) ans += 2*s; else ans = ans + i*s - (2-i)*p; if(ans > 0) cout << ans <<endl; else cout << "Deficit" << endl; } return 0; }
标签:div style code while name exce bsp efi log
原文地址:http://www.cnblogs.com/HackHer/p/6107841.html