UVa 11344 The Huge One:模性质

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2319

简单点的方法:由于a*10%m=((a%m)*10)%m,所以一个数一个数挨个取模判断即可。

复杂点的方法:

1. 1不用判断。

2. 若一个整数的未尾三位数能被8整除,则这个数能被8整除。

若一个整数的末尾两位数能被4整除,则这个数能被4整除。

若一个整数的个位能被2整除,则这个数能被2整除。

3. 若一个整数的数字和能被9整除,则这个整数能被9整除。

若一个整数的数字和能被3整除,则这个整数能被3整除。

4. 若一个整数能被2和3整除,则这个数能被6整除。

若一个整数能被3和4整除,则这个数能被12整除。

5. 若一个整数的末位是0,则这个数能被10整除。

若一个整数的末位是0或5,则这个数能被5整除。

6. 判定被7、11整除的简易方法(但此方法还不如上面的取模快)

7. 简化判断次数:

若8ok,则4,2ok;

若9ok,则3ok;

若2,3ok,则6ok;

若3,4ok,则12ok;

若10ok,则5ok。

完整代码:

01./*0.022s*/
02.
03.#include<cstdio>
04.#include<cstring>
05.
06.char s[1005];
07.int a[15];
08.
09.int main()
10.{
11.    int t, len, n, i, j, rem;
12.    bool f;
13.    scanf("%d", &t);
14.    while (t--)
15.    {
16.        getchar();
17.        gets(s);
18.        len = strlen(s);
19.        scanf("%d", &n);
20.        for (i = 0; i < n; ++i)
21.            scanf("%d", &a[i]);
22.        f = false;
23.        for (i = 0; i < n; ++i)
24.        {
25.            rem = 0;///remainder
26.            for (j = 0; j < len; ++j)
27.                rem = (rem * 10 + (s[j] & 15)) % a[i];
28.            if (rem)
29.            {
30.                f = true;
31.                break;
32.            }
33.        }
34.        if (f) printf("%s - Simple.\n", s);
35.        else printf("%s - Wonderful.\n", s);
36.    }
37.    return 0;
38.}

查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索scanf
, 方法
, excel模
, scanf gets
, 整数
, 个数
, rem
, 一个
, asp整除
, Huge
, 长整除
, javascript整除
判断整数
the huge florida、11344、11344 2008、winnietobehuge、huge boob girl大乳,以便于您获取更多的相关知识。

时间: 2024-11-05 12:33:03

UVa 11344 The Huge One:模性质的相关文章

UVa 128 Software CRC:模计算及CRC循环冗余校验码

128 - Software CRCTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=64 You work for a company which uses lots of personal computers. Your boss, Dr Penny Pi

UVa 10176 Ocean Deep !

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1117 思路和UVa 11344是一样的,只不过那题是10进制,这题是2进制. 完整代码: 01./*0.019s*/ 02. 03.#include<cstdio> 04. 05.int main() 06.{ 07. int mod; 08. c

UVa 374 Big Mod:快速幂取模

374 - Big Mod Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=310 Calculate for large values of B, P, and M using an efficient algorithm. (That's right, t

UVa 10183 How Many Fibs? (统计斐波那契数个数&amp;amp;高精度)

10183 - How Many Fibs? Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1124 Recall the definition of the Fibonacci numbers:    f1 := 1    f2 := 2    fn :

UVa 196:Spreadsheet

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=132 题目类型: 搜索, 拓扑排序 题目: In 1979, Dan Bricklin and Bob Frankston wrote VisiCalc, the first spreadsheet application. It became a

UVa 324 Factorial Frequencies:高精度

324 - Factorial Frequencies Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=260 In an attempt to bolster her sagging palm-reading business, Madam Phoenix

UVa 10198 Counting:组合数学&amp;amp;高精度

10198 - Counting Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1139 The Problem Gustavo knows how to count, but he is now learning how write numbers. As

UVa 424 Integer Inquiry (高精度)

424 - Integer Inquiry Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=365 One of the first users of BIT's new supercomputer was Chip Diller. He extended h

UVa 10106 Product:高精度

10106 - Product Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=1047 The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The In