1952-Lucky Sum of Digits
来源:互联网 发布:51单片机操作系统 编辑:程序博客网 时间:2024/05/16 06:43
Description
在数字界有一类被叫做幸运数的数,其实幸运数的组成很简单。如果一个数所有位数上的数字都是4或7的话就叫做幸运数。比如444444, 44747是幸运数而57774747就不是。
现在mwy遇到了一个小问题,他只知道一个幸运数所有位数上数字之和,他想知道这个数最小会是多少,聪明如你,快来帮帮我们的mwy吧。
Input
输入一个数n(n<=300)。
Output
如果可以找到这样的幸运数,就输出这个幸运数,否则就输出-1。
下附AC代码:
#include<stdio.h>int main() {int n, i;scanf("%d", &n);int s = 0, f = 0;s = n / 7;if (0 == (n - 7 * s) % 4) {f = (n - 7 * s) / 4;}elsewhile (s--) {if (0 == (n - 7 * s) % 4) {f = (n - 7 * s) / 4;break;}}if (0 == n || -1 == s) {printf("-1");}for (i = 0 ; i < f; ++i) {printf("4");}for (i = 0 ; i < s; ++i) {printf("7");}printf("\n");return 0;}
原题链接:http://acm.hznu.edu.cn/OJ/problem.php?cid=1091&pid=25
阅读全文
2 0
- 1952-Lucky Sum of Digits
- Lucky Sum of Digits
- A. Lucky Sum of Digits
- codeforces#84_div2_C Lucky Sum of Digits
- Codeforces 110C Lucky Sum Of Digits 暴力
- lucky sum of digit
- HDU3022:Sum of Digits
- HDU3022:Sum of Digits
- B. Sum of Digits
- Sum of Digits
- Ural 1658 Sum of Digits
- Timus 1658. Sum of Digits
- ural 1658. Sum of Digits
- URAL 1658. Sum of Digits
- Ural 1658 Sum of Digits
- B. Maximize Sum of Digits
- [Haskell] CodeWars|Sum of Digits
- URAL 1206 Sum of Digits of the Sum of Numbers
- 洗牌,发牌
- JVM的垃圾回收机制
- spring boot集成akka
- vb.net 教程 3-4 窗体编程 公共控件12 WebBrowser
- 同时替换栈中和.data中的Cookie突破GS
- 1952-Lucky Sum of Digits
- selenium 上传文件
- hdu1565 方格取数(1)(状压dp)
- 36. Valid Sudoku
- Java:用循环打印九九乘法表
- Android studio 电话号码归属地查询app简易版
- Codeforces 626E Simple Skewness(三分)
- css中的display属性
- Django 中间件