#55293: 少了輸入?WA (line:100003)


Ixcy (Ixcy)


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int k, i;
    for(i = 0; cin >> k; i++){
        int ans = k - k / 3;
        if(k % 3 == 0){
            cout << ans + 1;
        }
        else if(k % 3 == 1){
            cout << ans << " " << ans + 1;
        }
        else{
            cout << ans;
        }
        cout << '\n';
    }
}
這個程式應該能讀到EOF,但到100002行就結束了
#55297: Re: 少了輸入?WA (line:100003)


leeguanhan0909@gmail.com (李冠翰)


#include
using namespace std;
#define ll long long

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int k, i;
    for(i = 0; cin >> k; i++){
        int ans = k - k / 3;
        if(k % 3 == 0){
            cout << ans + 1;
        }
        else if(k % 3 == 1){
            cout << ans << " " << ans + 1;
        }
        else{
            cout << ans;
        }
        cout << '\n';
    }
}
這個程式應該能讀到EOF,但到100002行就結束了

這題k大小超過int限制,要用long long
程式停止是因為k>=2^31所以cin回傳flase