乞讨A。B。C ∈[1。N] && A*B != C,d(A*B) == d(C)组的数量。

首先要知道d(x) = (x%9 == 0 ? 9 : x%9);

那么则会有A*B == C,则必有d(A*B) == d(C)。

若不考虑A*B != C,则答案既是ans[x]*ans[y]*ans[d(x*y)],ans[x]为d(i) == x的个数,显然x∈[1,9]。

当考虑A*B != C时。则须要从ans[x]*ans[y]*ans[d(x*y)] - sum。

sum = sigma(n/i) , i ∈[1。n]。

int main()
{ int n,i,j,tmp; scanf("%d",&n); LL anw = 0; for(i = 1;i <= n; ++i)
{
ans[(tmp = i%9) == 0 ? 9 : tmp]++;
anw -= n/i;
} for(i = 1;i <= 9; ++i)
for(j = 1;j <= 9; ++j)
anw += ans[i]*ans[j]*ans[(tmp = (i*j)%9) == 0 ? 9 : tmp]; printf("%I64d\n",anw); return 0;
}

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

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 法冠军

    主题链接:点击打开链接 #include<stdio.h> #include<iostream> #include<string.h> #include<se ...

  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. 《转》VC++多线程编程

    原地址:http://www.cnblogs.com/wxfasdic/archive/2010/09/23/1833522.html 留个纪念,不错的总结.十个例子清晰列举啦多线程编程的奥妙.  V ...

  2. HP MSA2312 ERROR

    司在用的hp MAS2312存储其中一台每天都会报一个错误 EVENT:Vdisk verification failed. Command failed. (error code: 1) 2 err ...

  3. 基于DSP的疲劳驾驶检测系统的研究

    原地址:http://www.chinaaet.com/article/index.aspx?id=114534 关键词:疲劳检测DSP亮瞳效应PERCLOS 摘  要: 针对汽车驾驶员疲劳驾驶检测的 ...

  4. 使用Visual Studio 创建新的Web Part项目

    使用Visual Studio 创建新的Web Part项目 Web Part是你将为SharePoint创建的最常见的对象之中的一个.它是平台构建的核心基块. 1. 管理员身份打开Visual St ...

  5. 119 - Greedy Gift Givers

     Greedy Gift Givers  The Problem This problem involves determining, for a group of gift-giving frien ...

  6. Android-2手机应用程序,短信应用

    Activity生命周期   Android的核心组件 1.Viiew :界面 ,组织UI控件 2.Intent :意图,支持组件之间的通信 3.Activity:处理界面与UI互动 4.Conten ...

  7. 【Android小应用】颈椎保健操Android开源项目

    前段时间在知乎上回答已入 IT 行业的前辈,有哪些关于保护身体健康的知识分享给 IT 新人? ,回复了一张图片,评论里面有知友希望通过程序可以实现,我后面尝试着通过程序实现了效果,现开源出来,大家可以 ...

  8. 重温委托(delegate)和事件(event)

    1.delegate是什么 某种意义上来讲,你可以把delegate理解成C语言中的函数指针,它允许你传递一个类A的方法m给另一个类B的对象,使得类B的对象能够调用这个方法m,说白了就是可以把方法当作 ...

  9. 风起看云涌,叶落品人生 - Google 搜索

    风起看云涌,叶落品人生 - Google 搜索 风起看云涌,叶落品人生

  10. 美版SOLOWHEEL与盗版SOLOWHEEL-IPS独轮车终极PK【图】_厂商资讯_太平洋电脑网

    http://g.pconline.com.cn/x/330/3304676.html