CodeForces 10 C.Digital Root(数论)
来源:互联网 发布:老房子 顶层 知乎 编辑:程序博客网 时间:2024/06/17 03:05
Description
定义函数
问存在多少三元组
Input
一个整数
Output
输出满足条件的三元组
Sample Input
4
Sample Output
2
Solution
首先,
然后,求出所有满足
最后,求出不合法三元组从答案中减去,即满足
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;typedef pair<int,int>P;const int INF=0x3f3f3f3f,maxn=100001;int d(int x){ return (x-1)%9+1;}int num(int n,int x){ return n/9+(n%9>=x?1:0);}int main(){ int n; while(~scanf("%d",&n)) { ll ans=0; for(int i=1;i<=9;i++) for(int j=1;j<=9;j++) ans+=1ll*num(n,i)*num(n,j)*num(n,d(i*j)); for(int i=1;i<=n;i++)ans-=n/i; printf("%I64d\n",ans); } return 0;}
阅读全文
0 0
- CodeForces 10 C.Digital Root(数论)
- codeforces 10C C. Digital Root(数论)
- #10 C. Digital Root (数论)
- CodeForces 10C. Digital Root
- Codeforces 10C Digital Root 规律题
- SGU 118 Digital Root(数论)
- CF 10C Digital Root
- Eddy's digital Root hdu1163 数论
- [Codeforces] 355A - Vasya and Digital Root
- CodeForces 635C XOR Equation(数论)
- CodeForces 7C Line Exgcd(数论)
- CodeForces 7C Line Exgcd(数论)
- CodeForces 7C 【数论】
- Codeforces Round #372 (Div. 2) C. Plus and Square Root 数论、方程、化简、推公式
- Digital Root
- digital root
- digital root
- hdu 1013 Digital Roots(模拟 || 数论)
- 动态规划 python 实现 三角形最大值路径
- SDUT-3377-->数据结构实验之查找五:平方之哈希表
- 测量lisp小程序
- MyBatis自带的缓存配置(Cache)
- Leetcode Merge Two Sorted Lists 解题报告
- CodeForces 10 C.Digital Root(数论)
- 那些有趣又实用的开源人工智能项目 Top 10
- WannaflyUnion挑战赛6 A完全平方数
- Android获取手机制作商,系统版本等
- centos7程序自启动
- Bzoj1901 Dynamic Ranking
- 《Java 编程技巧1001条》 第403条 了解事件类
- 贪心
- 基于SparkStreaming对银行日志处理系列--整体技术框架