#10 C. Digital Root (数论)
来源:互联网 发布:vm数据区 编辑:程序博客网 时间:2024/06/05 06:43
题目链接:
点击打开链接
http://codeforces.com/contest/10/problem/C
题意:
定义
题解:
容斥原理,首先把所有的
然后减去
所以我们只需要减去
首先我们能够知道
然后我们通过记录数字根分别是
即
可以计算得到
然后用
AC代码:
#include<bits/stdc++.h>using namespace std;typedef long long ll;ll a[12];int main(){ int n; ll ans=0; ll ans1=0,ans2=0; cin>>n; for(int i=1;i<=n;i++){ a[i%9]++; ans1 += n/i; } for(int i=0;i<9;i++) { for(int j=0;j<9;j++) { ans2 +=a[i]*a[j]*a[i*j%9]; } } ans=ans2-ans1; cout<<ans<<endl; return 0;}
1 0
- #10 C. Digital Root (数论)
- CodeForces 10 C.Digital Root(数论)
- codeforces 10C C. Digital Root(数论)
- SGU 118 Digital Root(数论)
- CodeForces 10C. Digital Root
- CF 10C Digital Root
- Codeforces 10C Digital Root 规律题
- Eddy's digital Root hdu1163 数论
- Digital Root
- digital root
- digital root
- hdu 1013 Digital Roots(模拟 || 数论)
- HDU1163 Eddy's digital Roots(数论)
- HDU1013 Digital Roots 模拟&数论(我不会数论)
- HDU 4315 Digital root(线段树)
- hdu1013 digital root(数根)
- hdu1013 Digital Roots 数论
- HDOJ 1163 Eddy's digital Root (简单数论,但我也不会。。。。)
- ubuntu16.04 修改配置文件 禁止系统自动更新
- linux挂载光盘
- Android asmack使用介绍
- Java多线程/并发12、多线程访问static变量
- WEB-INF下页面跳转
- #10 C. Digital Root (数论)
- 在安卓中使用AnimationSet类同时执行多种动画效果
- spring+springMVC声明事物管理配置
- linux下yum源配置
- centos下搭建MySQL主从复制
- nyoj252 01串(动态规划)
- ACTION AIDL
- Python使用poster
- Python---BeautifulSoup 简单的爬虫实例