当前位置: 移动技术网 > IT编程>开发语言>C/C++ > 数据结构算法(统计给定乘法口诀矩阵中的因子)

数据结构算法(统计给定乘法口诀矩阵中的因子)

2020年08月05日  | 移动技术网IT编程  | 我要评论
原题链接:https://codeforces.com/problemset/problem/577/A题意;统计在给定乘法口诀矩阵中的因子。解题思路:遍历1到n,对另一个因子的范围进行判断统计即可。AC代码:/**邮箱:2825841950@qq.com*blog:https://blog.csdn.net/hzf0701*注:代码如有问题请私信我或在评论区留言,谢谢支持。*/#include<iostream>#include<cstdio>#include

原题链接:https://codeforces.com/problemset/problem/577/A

题意;统计在给定乘法口诀矩阵中的因子。

解题思路:遍历1到n,对另一个因子的范围进行判断统计即可。

AC代码:

/*
*邮箱:2825841950@qq.com
*blog:https://blog.csdn.net/hzf0701
*注:代码如有问题请私信我或在评论区留言,谢谢支持。
*/ #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<string> #include<stack> #include<queue> #include<cstring> #include<map> #include<iterator> #include<list> #include<set> #include<functional> #include<memory.h>//低版本G++编译器不支持,若使用这种G++编译器此段应注释掉 #include<iomanip> #include<vector> #include<cstring> #define scd(n) scanf("%d",&n) #define scf(n) scanf("%f",&n) #define scc(n) scanf("%c",&n) #define scs(n) scanf("%s",n) #define prd(n) printf("%d",n) #define prf(n) printf("%f",n) #define prc(n) printf("%c",n) #define prs(n) printf("%s",n) #define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增 #define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。 #define pb push_back #define fi first #define se second #define mp make_pair using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; const ll inf = 0x3f3f3f3f;//无穷大 const ll maxn = 1e5;//最大值。 //*******************************分割线,以上为代码自定义代码模板***************************************// ll n,x,sum; int main(){ //freopen("in.txt", "r", stdin);//提交的时候要注释掉 ios::sync_with_stdio(false);//打消iostream中输入输出缓存,节省时间。 cin.tie(0); cout.tie(0);//可以通过tie(0)(0表示NULL)来解除cin与cout的绑定,进一步加快执行效率。 while(cin>>n>>x){ sum=0; rep(i,1,n){ if(x%i==0&&(x/i<=n)){ sum++; } } cout<<sum<<endl; } return 0; } 

本文地址:https://blog.csdn.net/hzf0701/article/details/107771706

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网