首页 > 其他分享 >Eddy's digital Roots 1163 (数学+九余数定理)

Eddy's digital Roots 1163 (数学+九余数定理)

时间:2023-04-20 12:09:52浏览次数:28  
标签:digit 1163 int single Eddy digital integer root


Eddy's digital Roots


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5278    Accepted Submission(s): 2952



Problem Description


The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.

The Eddy's easy problem is that : give you the n,want you to find the n^n's digital Roots.




Input


The input file will contain a list of positive integers n, one per line. The end of the input will be indicated by an integer value of zero. Notice:For each integer in the input n(n<10000).




Output


Output n^n's digital root on a separate line of the output.




Sample Input


2 4 0




Sample Output


4 4


//九余数定理


#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	while(scanf("%d",&n),n)
	{
		int a;
		a=n;
		for(int i=2;i<=n;i++)
			a=a*n%9;
		if(a==0)
			printf("9\n");
		else
			printf("%d\n",a);
	}
	return 0;
}


标签:digit,1163,int,single,Eddy,digital,integer,root
From: https://blog.51cto.com/u_16079508/6209371

相关文章

  • Vulnhub:Digitalword.local (FALL)靶机
    kali:192.168.111.111靶机:192.168.111.130信息收集端口扫描nmap-A-v-sV-T5-p---script=http-enum192.168.111.130访问test.php,提示缺少参数漏洞利用wfuzz爆破参数wfuzz-c-w/opt/zidian/SecLists-2022.2/Discovery/Web-Content/burp-parameter-names.txt--hc......
  • 中国数字前行者共同发声:Digital, Give me five
    穷则变,变则通,通则久。——语出《系辞·下》这世界上唯一不变的就是变化,20多位来自各行业的数字前行者共同发声:Digital, givemefive!击掌的瞬间,缘,妙不可言。 变变变,一切都在变!改革开放40多年的发展,不仅改变了中国的命运,同样也改变了每一个中国人的生活。对比一下40年前与40年后,......
  • Vulnhub:Digitalworld.local (Development)靶机
    kali:192.168.111.111靶机:192.168.111.130信息收集端口扫描nmap-A-v-sV-T5-p---script=http-enum192.168.111.130查看网站首页源码访问development目录,提示存在一个流量包查看流量包发现另一个网站路径:/developmentsecretpage/directortestpagev1.php访问该路......
  • nodejs新版本引起的:digital envelope routines::unsupported
    一、起因#由于电脑重装系统,重新下载nodejs,自然更新到最新版本18,之前的版本才16。更新到最新nodejs版本后,运行vue文件,报错:this[kHandle]=new_Hash(algorithm,xofLen);^Error:error:0308010C:digitalenveloperoutines::unsupported  二、探索#常规操作,上网查原因:......
  • Node.js17或更高版本中出现Error: error:0308010C:digital envelope routines::unsupp
    问题描述我在运行别人的Vue项目的时候报各种错误,提示XXX/node_modules/.bin/vue-cli-service:Permissiondenied权限不足的问题。还有一个问题就是:出现Error:error:0308010C:digitalenveloperoutines::unsupported。在网上也查看了解决办法,没有解决。(我之前在Nodejs官网安装......
  • 【THM】Intro to Digital Forensics(数字取证介绍)-学习
    本文相关的TryHackMe实验房间链接:https://tryhackme.com/room/introdigitalforensics本文相关内容:了解数字取证及其相关流程,并完成相关的简单实例。简介取证是指应用科......
  • Error message "error:0308010C:digital envelope routines::unsupported"
    由于升级Nodejs版本造成的,一般创建项目时为16.7.0版本,然后安装或升级了更高版本,再进行run的时候,会提示。Errormessage"error:0308010C:digitalenveloperoutines::unsu......
  • P1163 银行贷款(小数二分)
    P1163银行贷款分析变量命名如下:\(n\)表示贷款的原值,\(m\)表示每月支付的分期付款金额,\(k\)表示分期付款还清贷款所需的总月数。\(p\)表示贷款的月利率第......
  • 0308010C:digital envelope routines::unsupported
    node.js为全新版本Node.jsv18.15.0。许多网站说是因为node版本过高,需要降级。可以参考如下步骤和代码来进行。把:"scripts":{"serve":"vue-cli-serviceserve"......
  • ruoyi-vue启动报错error:03000086:digital envelope routines::initialization error
    原因分析可能是因为node是最新版本导致ERR_OSSL_EVP_UNSUPPORTED错误SSL数字信封不支持解决措施(ps:网上找的)setNODE_OPTIONS=--openssl-legacy-provider亲测并......