乞讨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. ural 1519 Formula 1

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1519 题目分类:插头dp 题意:求经过所有可行点的哈密顿回路的个数  * 不可走 . 可 ...

  2. Delphi基础Write写入结构体到文件(使用 file of myrecord就行了,真简单)

    program WriteStruct; {$APPTYPE CONSOLE} uses SysUtils; //写入结构体 type TCustomer = record ID: ]; Code: ...

  3. Easyui 让Window弹出居中

    原文:Easyui 让Window弹出居中 easyui1.3.2版本,window的弹出不会居中了.而dialog是会居中的,我们必须为为window的open事件做扩展 代码如下:只要加入以下代码 ...

  4. hdu1824(two-sat)

    传送门:Let's go home 题意:有n个队伍要回家,但是每队必须留下一人,而且m个限制,a留下,b必须回家,问能否在限制条件下每队留下一人. 分析:将每个队的队长和两个队员当成i和i':然后对 ...

  5. UVA 11080 - Place the Guards(二分图判定)

    UVA 11080 - Place the Guards 题目链接 题意:一些城市.之间有道路相连,如今要安放警卫,警卫能看守到当前点周围的边,一条边仅仅能有一个警卫看守,问是否有方案,假设有最少放几 ...

  6. VLine2.0——仿阿里巴巴VIPABC真人视频在线教育(基于Flash支持一对多多对多Web在线视频)

    感兴趣的朋友可与我联系:acsebt@qq.com 一.登陆页 二.功能页

  7. Fashion Meets Finance聚会来袭-7月19日 北京

    http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjEzMjMyMQ%3D%3D&appmsgid=10000704&itemidx= ...

  8. NGUI使用教程(3) 使用外部图片制作Atlas(图集)

    在实际操作之前有几个概念先弄清一下 Atlas:图集,把美术给你提供的素材,用 NGUI 的 Atlas Maker 工具.合成一张图片(准确的说,还同一时候生成了prefab.mat ). Spri ...

  9. IE浏览器审查密码的清除

    上周去188工业区,总装厂的喷油部的电脑上被谁设置了IE的审查密码,后来通过电话沟通,运维岗给出了具体的解决方法: 进入注册表HKEY_LOCAL_MACHINE\Software\Microsoft ...

  10. Makefile分析基础

    http://blog.csdn.net/ghostyu/article/details/6866863 在我前一篇写的[ linux驱动学习(一)Makefile基础]中,Makefile写的中规中 ...