[ACM ] ZeroJudge d136:共同的數

看板C_and_CPP (C/C++)作者 (怕就輸了)時間16年前 (2009/03/14 01:01), 編輯推噓1(107)
留言8則, 3人參與, 最新討論串1/2 (看更多)
http://cat.nknush.kh.edu.tw/ZeroJudge/ShowProblem?problemid=d136 以下是我的程式 (C++) #include <iostream> #include <sstream> using namespace std; int main(){ int testData,Num; cin>>testData>>Num; cin.get(); while(testData--){ long long int Aaa=0,Bbb,Ccc=Num,count=0; string str; getline(cin,str); stringstream lineA(str); lineA>>Aaa; cin>>Bbb; --Ccc; while(Ccc+1&&!lineA.fail()){ if(Bbb>Aaa){ lineA>>Aaa; } else if(Bbb<Aaa){ if(Ccc--){ cin>>Bbb; } else break; } else{ count++; lineA>>Aaa; if(Ccc--){ cin>>Bbb; } else break; } } cout<<count<<endl; cin.get(); } system("pause"); return 0; } 一直拿WA.. 自己在dev-c上測試看不出問題...請問哪邊有錯誤呢.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.232.69.157

03/14 01:28, , 1F
你確定它只測試一組資料?
03/14 01:28, 1F

03/14 01:30, , 2F
有將測資的筆數讀入耶..testData那個變數..
03/14 01:30, 2F

03/14 01:35, , 3F
你確定它只輸入一次testData?
03/14 01:35, 3F

03/14 02:11, , 4F
嗯嗯~ 這是種可能性! 但是剛剛試了一下,也是不行耶..
03/14 02:11, 4F

03/14 02:28, , 5F
資料型態用 unsigned long long int //我錯好多次orz
03/14 02:28, 5F

03/14 14:08, , 6F
這題似LCS
03/14 14:08, 6F

03/14 17:21, , 7F
囧..改unsigned還是錯..他說我line 2答案是0...
03/14 17:21, 7F

03/14 18:10, , 8F
要不要更新一下文章
03/14 18:10, 8F
文章代碼(AID): #19kf5Iqp (C_and_CPP)
文章代碼(AID): #19kf5Iqp (C_and_CPP)