zoukankan      html  css  js  c++  java
  • Codeforces 10C Digital Root 法冠军

    主题链接:点击打开链接


    #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
    ",ans);
    	}
    	return 0;
    }
    /*
    2
    1 2
    3
    1 2 3
    
    */


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

  • 相关阅读:
    CSS的扩展less和sass
    html5小游戏基础知识
    htm5拖放和画布
    htm5
    并查集模板
    二叉树的建树
    kmp的书写
    贪心算法
    容器
    POJ2442 优先队列
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4803364.html
Copyright © 2011-2022 走看看