###### 丙三醇

Stupid boy learn programming . QQ交流：792883735

###### SGU118——Digital Root
 118. Digital Root time limit per test: 0.5 sec. memory limit per test: 4096 KB Let f(n) be a sum of digits for positive integer n. If f(n) is one-digit number then it is a digital root for n and otherwise digital root of n is equal to digital root of f(n). For example, digital root of 987 is 6. Your task is to find digital root for expression A1*A2*…*AN + A1*A2*…*AN-1 + … + A1*A2 + A1. Input Input file consists of few test cases. There is K (1<=K<=5) in the first line of input. Each test case is a line. Positive integer number N is written on the first place of test case (N<=1000). After it there are N positive integer numbers (sequence A). Each of this numbers is non-negative and not more than 109. Output Write one line for every test case. On each line write digital root for given expression. Sample Input 1 3 2 3 4  Sample Output 5  首先，比如样例三个数字，要求是2*3*4+2*3+2，可以这么看2+2*3+2*3*4  还有两个数论公式：（a+b）%c=(a%c)+(b%c)    (a*b)%c=(a%c)*(b%c)  还有一个结论是一个数的所有位数的和为这个数对9取模。   `#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int t,n,a; scanf("%d",&t); while(t--) { int p=1,sum=0; scanf("%d",&n); for(int i=0;i

#### sgu118：Digital root

2014-10-18 20:29:28

#### SGU118 Digital Root

2015-05-23 21:13:30

#### 【九度OJ】题目1124：Digital Roots 解题报告

2017-03-05 22:07:36

#### CodeForces 10C. Digital Root

2014-10-26 20:43:21

#### 树根Digital root算法

2015-09-01 13:32:54

#### You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store Fetching:

2017-07-31 14:51:33

#### 杭电OJ--1013 Digital Roots

2012-09-23 17:53:25

#### codeforces 10C C. Digital Root(数论)

2015-09-01 10:35:13

#### 数根(digital root)公式的推导

2017-01-03 08:50:24

#### Digital Roots (题目虽水，解法不可水)

2013-12-12 23:15:28

## 不良信息举报

SGU118——Digital Root