用给定数目的单位方块,问能拼成多少种矩形。暴力求解。。
#include<cstdio> #include<cmath> int n,i,j,ans; int main(){ scanf("%d",&n); for (i=1;i<=n;i++){ for (j=1;j<=int(sqrt(double(i)));j++){ if (i%j==0)ans++; } } printf("%d\n",ans); }
用给定数目的单位方块,问能拼成多少种矩形。暴力求解。。
#include<cstdio> #include<cmath> int n,i,j,ans; int main(){ scanf("%d",&n); for (i=1;i<=n;i++){ for (j=1;j<=int(sqrt(double(i)));j++){ if (i%j==0)ans++; } } printf("%d\n",ans); }
转载于:https://www.cnblogs.com/moris/p/4314295.html