NEUOJ 1681

The Singles

时间限制: 1 Sec   内存限制: 128 MB
提交: 272   解决: 66
[ 提交][ 状态][ 讨论版]

题目描述

The Signals’ Day has passed for a few days. Numerous sales promotion campaigns on the shopping sites make us forget that 11.11 is the Signals’ Day. So we should do something to enhance the concept of Singles’ Day. 

Let’s give a number a, you should find the minimum number n only consist of digit 1(ie. 111,11111…) which can be divided by a. If the number exist, you should output "Singles' Day is on n.", otherwise you should output "There is no Singles' Day!".

输入

Several test cases.

For each test case:

Input is a integer a(1<=a<=1000000),as described above.

输出

For each test case:

Output "Singles' Day is on n." or  "There is no Singles' Day!" in one line.

样例输入

1
2
3

样例输出

Singles' Day is on 1.
There is no Singles' Day!
Singles' Day is on 111.


//
//  1681.c
//
//  Created by XFang on 16/02/18
//  Copyright ©2016 XFang. All rights reserved.
//

#include<stdio.h>
int main(){
    unsigned long long i,a,r;
 while(scanf("%llu",&a)!=EOF){
     r=0;
        if(a%2==0||a%5==0) {
            printf("There is no Singles' Day!\n");
        }
        else {
            for(i=1;;i=i*10+1){
                r++;
                i=i%a;
                if(i%a==0) {
                    break;
                }
            }
            printf("Singles' Day is on ");
            for(i=0;i<r;i++)
                printf("1");
            printf(".\n");
        }
    }
    return 0;
}


本来是道大水题,可是挺多人挂的,给自己留个提醒吧!
应该是取模运算的应用。
看来是时候看看数论了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值