Re: [ACM] 新手問一下
看板C_and_CPP作者vic1225 (/* I'm not worth */)時間15年前 (2010/08/05 23:52)推噓1(1推 0噓 13→)留言14則, 4人參與討論串2/2 (看更多)
※ 引述《vic1225 (/* I'm not worth */)》之銘言:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=36
ACM題目 像這題
就是要input然後輸出output
我想問的是她input的是要我寫成讀檔嗎?
還是cin給他輸入呢? (要cout提示他要輸入嗎?)
然後output是直接cout嗎 還是要輸出到檔案?
第一次玩這種題目不清楚
希望大神們指教一下 謝謝!!
這是題目id 100
我的code如下
#include <iostream>
using namespace std;
int count_number_of_cycle(int n, int t);
int main(){
cout << "輸入 x y" << endl;
int x, y;
cin >> x >> y;
int max = 0; int temp = 0;
//find max cycle between x, y
for(int i = x; i <= y; i++){
if(max < (temp = count_number_of_cycle(i, 0)))
max = temp;
}
cout << x << " " << y << " " << max << endl;
system("pause");
return 0;
}
int count_number_of_cycle(int n, int count){
if(n == 1) return count + 1;
else if(n % 2 == 0) return count_number_of_cycle(n / 2, count + 1);
else return count_number_of_cycle(3 * n + 1, count + 1);
}
我自己測試都吻合阿
他卻說我wrong answer = =
是怎麼回事阿 output格式錯誤嗎?
感謝指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.246.124
→
08/05 23:33,
08/05 23:33
→
08/05 23:38,
08/05 23:38
→
08/05 23:39,
08/05 23:39
→
08/05 23:39,
08/05 23:39
→
08/05 23:40,
08/05 23:40
→
08/05 23:40,
08/05 23:40
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.246.124
推
08/05 23:52, , 1F
08/05 23:52, 1F
→
08/05 23:53, , 2F
08/05 23:53, 2F
→
08/05 23:53, , 3F
08/05 23:53, 3F
→
08/05 23:54, , 4F
08/05 23:54, 4F
→
08/06 00:05, , 5F
08/06 00:05, 5F
→
08/06 00:07, , 6F
08/06 00:07, 6F
→
08/06 00:08, , 7F
08/06 00:08, 7F
→
08/06 00:08, , 8F
08/06 00:08, 8F
→
08/06 00:09, , 9F
08/06 00:09, 9F
→
08/06 00:09, , 10F
08/06 00:09, 10F
→
08/06 00:10, , 11F
08/06 00:10, 11F
→
08/06 00:10, , 12F
08/06 00:10, 12F
→
08/06 00:10, , 13F
08/06 00:10, 13F
→
08/06 00:11, , 14F
08/06 00:11, 14F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):