主题链接:点击打开链接

#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. Hello World! 2010年山东省第一届ACM大学生程序设计竞赛

    Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...

  2. XMPP得知--建立一个管理类

    参考其他demo之后,设立一个管理类的发现看起来更舒服,理-- 但在建立与server连接其中.发现 Connect Error: {     NSLocalizedDescription = &qu ...

  3. HDU 1018-Big Number(数学)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  4. 【C语言探索之旅】 第二部分第九课: 实战"悬挂小人"游戏 答案

    内容简介 1.课程大纲 2.第二部分第九课: 实战"悬挂小人"游戏 答案 3.第二部分第十课预告: 安全的文本输入 课程大纲 我们的课程分为四大部分,每一个部分结束后都会有练习题, ...

  5. 了解HTML5和“她”的 API (二)

    Communication(通信)     Cross Document Messaging (跨文档消息通信) postMessage API   origin security(源安全) chat ...

  6. 【转】Directx11 HelloWorld之HLSL的Effect框架的使用

    最近尝试用了下Directx下的Effect框架,作为一初学者初学者,说下为什么我们要使用Effect框架及其好处吧. 首先Effect最大好处的就是简单,使得编写Shader绘制的程序工作量大大下降 ...

  7. Akka.NET是Java/Scala 流行框架Akka的一个 .NET 开源移植

    Akka.NET v1.0 已发布,支持Mono Akka.NET 是Java/Scala 流行框架Akka的一个 .NET 开源移植.可用于构建高并发,分布式和容错事件驱动的应用在 .NET 和 M ...

  8. MMTool制作Ozmosis引导BIOS完美引导OS X系统

    Ozmosis引导是德国黑苹果爱好者制作的一个引导程序,目前仍处于测试版,有了它,你可以不用再使用四叶草.变色龙之类引导工具,相对而言它更象白苹果.Ozmosis是基于AMI公司bios的硬件引导驱动 ...

  9. JTextArea Demo

    在往JTextArea中填充数据时,JTextArea上的滚动条也可以拖动.解决办法:主线程放在EDT中,fill JTextArea的操作放在另外一个线程中,这样fill操作与GUI上的操作就分离了 ...

  10. Phoenix(sql on hbase)简单介绍

    Phoenix(sql on hbase)简单介绍 介绍: Phoenix is a SQL skin over HBase delivered as a client-embedded JDBC d ...