还是十分简单啊...
要注意 x=0 的情况,不需要输出,直接 return 0 即可:
x=0
return 0
#include<iostream> #include<cmath> #include<algorithm> #define QwQ return 0; using namespace std; int n,x,y; int main(){ cin>>n>>x>>y; if(x==0){ QwQ } cout<<max(n-ceil(y*1.0/x),0.0); QwQ }
n,x,y=input().split() n=int(n) x=int(x) y=int(y) eat=0 if y%x!=0: eat=(y-(y%x))/x+1 else: eat=y/x print(int(n-eat))
#include<bits/stdc++.h> using namespace std; int n,x,y; signed main(){ cin>>n>>x>>y; if(x==0)return 0; else cout<<n-ceil(y*1.0/x); }
蒙掉了,五个测试点有 444 个空白代码都有分。然后呢?我的“正解”交上去只对了一个点。
#include<bits/stdc++.h> #define int long long #define INF 0x3f3f3f using namespace std; int n,x,y; signed main(){ cin>>n>>x>>y; if(x==0);//应该是输出 0 才对啊 else if(y%x==0)cout<<n-y/x; else cout<<n-y/x-1; return 0; }
警示后人:你谷代码都没过,直接看官解:不是哥们,为什么 x=0x=0x=0 的时候它直接要 return 0; 啊!!!
return 0;
#include<bits/stdc++.h> using namespace std; int main(){ int m,t,s; cin>>m>>t>>s; if(t==0) { return 0; } else { cout<<max(m-int(ceil(s*1.0/t)),0); } return 0; }
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if(b==0){ return 0; } cout<<a-c/b-1; return 0; }
Python :
# coding=utf-8 n,x,y = input().split () n = int (n) x = int (x) y = int (y) a = int (y / x) print (y - a)
注册一个 QZ 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。
使用您的 QZ 通用账户