首页 > 代码库 > usaco-4.1-nuggets-passed
usaco-4.1-nuggets-passed
呵呵,这个数论题
/*ID: qq104801LANG: C++TASK: nuggets*/#include <iostream>#include <fstream>#include <cstring>#include <vector>#include <queue>#include <stack>#include <algorithm>using namespace std;#define nmax 79500int d[500000],temp,n;void test(){ freopen("nuggets.in","r",stdin); freopen("nuggets.out","w",stdout); d[0]=1; cin>>n; while(n--) { cin>>temp; for(int i=temp;i<=nmax;i++)if(d[i-temp])d[i]=1; } temp=0; for(int i=nmax;i>=0;i--)if(!d[i]){temp=i;break;} for(int i=nmax;i>=79000;i--)if(!d[i]){temp=0;break;} cout<<temp<<endl; }int main () { test(); return 0;}
test data :
USACO TrainingGrader Results 13 users onlineAUT/1 BGD/1 CHL/1 CHN/7 GBR/1 IND/1 SWE/1USER: cn tom [qq104801]TASK: nuggetsLANG: C++Compiling...Compile: OKExecuting... Test 1: TEST OK [0.005 secs, 5324 KB] Test 2: TEST OK [0.005 secs, 5324 KB] Test 3: TEST OK [0.008 secs, 5324 KB] Test 4: TEST OK [0.008 secs, 5324 KB] Test 5: TEST OK [0.005 secs, 5324 KB] Test 6: TEST OK [0.008 secs, 5324 KB] Test 7: TEST OK [0.014 secs, 5324 KB]All tests OK.YOUR PROGRAM (‘nuggets‘) WORKED FIRST TIME! That‘s fantastic -- and a rare thing. Please accept these special automated congratulations.Here are the test data inputs:------- test 1 ----33610------- test 2 ----223------- test 3 ----11------- test 4 ----4252250254256------- test 5 ----2255254------- test 6 ----5251252250254256------- test 7 ----10238240242244246248250252254255Keep up the good work!Thanks for your submission!
usaco-4.1-nuggets-passed
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。