2 条题解
-
2_Administrator_ LV 7 MOD @ 2020-03-02 20:00:55
一道很简单的题,首先定义两个double型变量,相除再上取整就没了!
下面是代码:#include <iostream> #include <cmath> using namespace std; int main() { double a, b; cin >> a >> b; double s=a/b; cout << ceil(s) << endl; return 0; }
-
12020-03-04 18:36:58@
楼上说的可以过,这里补充一种:ceil(x/y)=floor((x+y-1)/y)
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> #define For(i,j,k) for(int i=j;i<=(k);++i) using namespace std; typedef long long ll; inline int read(){ int x=0,w=0;char c=getchar(); for(;c<'0'||c>'9';w^=c=='-',c=getchar()); for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar()); return w?-x:x; } int qpow(int n,int m,int k){ //n^m%k if(m==0) return 1; int ans=qpow(n,m/2,k)%k; if(m%2) return ans*ans%k*ans%k; return ans*ans%k; } int main(){ int x,y; cin>>x>>y; cout<<(x+y-1)/y; return 0; }
- 1