tommyf22a 10 發表於 December 22, 2007 檢舉 Share 發表於 December 22, 2007 做ACM一直wrong answer(Q100)有人可以幫我看看嗎#include<iostream>using namespace std;int main(){ long a,b,c,d=1,e=1; cin>>a; cin>>b; cout<<a; cout<<b; if(a<b){ for(long t=a;t<=b;t++){ c=t; while(c!=1){ if (c%2==1) c=c*3+1; else c=c/2; d++; } if (d>e) e=d; d=1; }} else { for(long t=b;t<=a;t++){ c=t; while(c!=1){ if (c%2==1) c=c*3+1; else c=c/2; d++; } if (d>e) e=d; d=1; }} cout<<e;} 不過似乎是很簡單的題目我是新手 鏈接文章 分享到其他網站
jim2212001 10 發表於 December 22, 2007 檢舉 Share 發表於 December 22, 2007 http://luckycat.kshs.kh.edu.tw/看一下裡面Q100有參考的Code基本上來說ACM做測試的時候會有很多筆測資而且是一次全部輸入到程式裡面每題判斷結束的方法不一樣最常見的就是EOF詳情請問C講師或演算法講師(茶) 鏈接文章 分享到其他網站
lachu 10 發表於 December 25, 2007 檢舉 Share 發表於 December 25, 2007 請把第一次cin的地方改成while(cin >> ...){while的結尾在答案輸出的後面這樣程式才可以輸入多組測資詳情請問演算法講師 鏈接文章 分享到其他網站
lachu 10 發表於 December 26, 2007 檢舉 Share 發表於 December 26, 2007 我們在測試的時候不會結束但是傳上去ACM的時候他是用檔案輸入所以讀到結尾才會跳出 鏈接文章 分享到其他網站
kelvin 10 發表於 February 24, 2008 檢舉 Share 發表於 February 24, 2008 感覺好像lag了若干個月..@@||不過還是補充一下要直接在螢幕上模擬EOF可以打ctrl+z就是EOF了 鏈接文章 分享到其他網站
Recommended Posts