Re: [ACM ] ZeroJudge d136:共同的數
以下是修正一些可能的錯誤後,我的程式碼..
還是一直WA,錯在line2 正確答案:39846 我的答案:0
能幫我看一下還有哪邊有問題嗎..
#include <iostream>
#include <sstream>
using namespace std;
int main(){
int testData,Num;
while(cin>>testData>>Num){
while(testData--){
cin.get();
unsigned 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;
}
}
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.232.84.45
→
03/15 01:13, , 1F
03/15 01:13, 1F
→
03/15 01:17, , 2F
03/15 01:17, 2F
→
03/15 02:13, , 3F
03/15 02:13, 3F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章