乞讨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. qt 获取windows 的消息(通过MFC的DLL的透明窗体转发消息)good

    qt 给win32 发送消息很简单,但是要获取windows 消息却十分复杂,最后想了一个不是很完美 但是也是以现在本人能力所能实现的唯一途径了,基本原理是 利用vc编写一个mfc 的dll ,这个d ...

  2. 怎样在Android本地视频播放器开发

    在上一章Android本地视频播放器开发--SDL编译编译中编译出sdl的支持库,当时我们使用的2.0,但是有些api被更改了,所以在以下的使用者中我们使用SDL1.3的库,这个库我会传上源码以及编译 ...

  3. Transparency Tutorial with C# - Part 2

    Download Compositing Mode demo project - 24 Kb Download Compositing Mode source - 26 Kb Download Com ...

  4. MySQL字符串函数、日期时间函数

    MySQL字符串函数.日期时间函数 一.常见字符串函数: 1.CHAR_LENGTH  获取长度(字符为单位) 2.FORMAT  格式化 3.INSERT  替换的方式插入 4.INSTR  获取位 ...

  5. Amazon.com : The Odyssey of the Manual Toothbrusher

    Amazon.com : The Odyssey of the Manual Toothbrusher The Odyssey of the Manual Toothbrusher

  6. xcode多target

    原文:http://www.codza.com/free-iphone-app-version-from-the-same-xcode-project There are more than 15,0 ...

  7. Maven安装中的问题

    按照<Maven实战>中的讲述,在安装完Maven后执行mvn -v的时候,出现了问题.在网上搜索到了解决办法: 引用:http://blog.csdn.net/xueyepiaoling ...

  8. Qt调用word 例子

    Qt调用word 例子 Getting Microsoft Word Object to SaveAs #include <QtGui> #include <QAxObject> ...

  9. 对consistencygroup的一些研究和实践

    声明: 本博客欢迎转载,但请保留原作者信息! 作者:李人可 团队:华为杭州OpenStack团队 consistency group,直译是一致性组,是Juno版本号cinder新引进的一个概念.顾名 ...

  10. 项目之软件project(我专业四年都未曾知道这四个字的含义,几句话便懂了)

    潘鹏在CSDN上原创.如其它站点转载请注意排版和写明出处: 软件project的本质 一级标题 控制 质量 二级标题  成本  扩展  高内聚低耦合 效率 控制: 成本:企业要求的是以最快的速度完毕可 ...