[ACM ] ZeroJudge d136:共同的數
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
03/14 01:30, 2F
→
03/14 01:35, , 3F
03/14 01:35, 3F
→
03/14 02:11, , 4F
03/14 02:11, 4F
→
03/14 02:28, , 5F
03/14 02:28, 5F
→
03/14 14:08, , 6F
03/14 14:08, 6F
→
03/14 17:21, , 7F
03/14 17:21, 7F
推
03/14 18:10, , 8F
03/14 18:10, 8F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章