主题链接:点击打开链接

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 1000005
#define ll __int64
ll num[10],n;
ll go(ll x){
ll ans = x;
while(ans>=10){
ans = 0;
while(x) {
ans += x%10;
x /= 10;
}
x = ans;
}
return ans;
}
int main(){
ll i,j,k;
while(~scanf("%I64d",&n))
{
memset(num, 0, sizeof num);
ll ans = 0;
for(i=1;i<=n;i++) num[go(i)]++, ans -= n/i; for(j=0;j<10;j++)
for(k=0;k<10;k++)
ans+=num[k]*num[j]*num[go(k*j)];
printf("%I64d\n",ans);
}
return 0;
}
/*
2
1 2
3
1 2 3 */

版权声明:本文博主原创文章,博客,未经同意不得转载。

Codeforces 10C Digital Root 法冠军的更多相关文章

  1. codeforces 10C Digital Root(非原创)

    Not long ago Billy came across such a problem, where there were given three natural numbers A, B and ...

  2. CodeForces 10C. Digital Root

    乞讨A.B.C ∈[1.N] && A*B != C,d(A*B) == d(C)组的数量. 首先要知道d(x) = (x%9 == 0 ? 9 : x%9); 那么则会有A*B == ...

  3. Codeforces Beta Round #10 C. Digital Root 数学

    C. Digital Root 题目连接: http://www.codeforces.com/contest/10/problem/C Description Not long ago Billy ...

  4. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  5. Digital root(数根)

    关于digital root可以参考维基百科,这里给出基本定义和性质. 一.定义 数字根(Digital Root)就是把一个数的各位数字相加,再将所得数的各位数字相加,直到所得数为一位数字为止.而这 ...

  6. 数字根(digital root)

    来源:LeetCode 258  Add Dights Question:Given a non-negative integer  num , repeatedly add all its digi ...

  7. 【HDOJ】4351 Digital root

    digital root = n==0 ? 0 : n%9==0 ? 9:n%9;可以简单证明一下n = a0*n^0 + a1*n^1 + ... + ak * n^kn%9 = a0+a1+..+ ...

  8. Sum of Digits / Digital Root

    Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...

  9. digital root问题

    问题阐述会是这样的: Given a non-negative integer num, repeatedly add all its digits until the result has only ...

随机推荐

  1. defgen工具

    构造defgen档 由于 Oracle 和 SQL Server 中的数据类型不同.所以您必须建立数据类型转换.GoldenGate 提供了一个名为 DEFGEN 的专用工具.用于生成数据定义,当源表 ...

  2. Cookie rejected: Illegal path attribute &quot;/nexus&quot;. Path of origin: &quot;/content/&quot; 解

    问题叙述性说明 通过运行"mvn clean deploy" 命令 将 Maven 项目公布 Nexus 当PW.举例控制台输出以下警告消息: [INFO] Downloaded: ...

  3. Apple Swift编程语言入门

    1   简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Programming Language>中摘录和提取而成.希望对各位的iOS&a ...

  4. 矢量编程——随着MNIST案例

    矢量编程使用的所有明确的矢量运算,而不是for周期. 上一节所用的是512*512*10的数据集非常小.我们取的patch非常小(8*8),学来的特征非常少(25).而我又凝视掉了梯度校验(偷懒),所 ...

  5. POJ9384 迷宫(基金会BFS)

    本文来源于:http://blog.csdn.net/svitter 称号:让你从(0, 0)走到(4,4).而且输出路径. 输入数据:二位数组的迷宫:输出数据:路径: 题解:简单的BFS 注意: 1 ...

  6. oracle一视图性能问题

    oracle一些性能视图的解释  --关于是否收集 timed_statistics参数:用于决定是否收集相关的时间参数,true为收集.如果该参数设为false,则等待事件相关视图也就无法收集到数据 ...

  7. 如何使用 iOS 7 的 AVSpeechSynthesizer 国家有声读物(4)

    控制:我们一定要学会控制 尤达大师(电影<星球大战>)有话:的关键在于控制.这本故事书是一个字一个字读出来,我愿意为它添加两个button,音调和语速,以便我们能够调整语音合成实时的时候. ...

  8. poj2096--Collecting Bugs(可能性dp第二弹,需求预期)

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 2678   Accepted: 1302 ...

  9. Spring Framework 下载链接_现在有空

    下载链接:http://repo.spring.io/libs-release-local/org/springframework/spring/ 点击打开链接 包括Spring的各个版本号: 3.2 ...

  10. Unity3d 网络编程(三)(Unity3d内置简单的网络server编制)

    使用Unity3d内置的网络建立一个简单的server.主机时,请使用机器.创建一个client连接到本机. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv ...