新手村 Boss战-入门综合练习1 三连击(升级版)
2017-12-08 10:31
381 查看
题目链接
欢迎加入“不会算法一群菜鸟”,群号是⑥⑥①⑨②2025,这是我设置的一道很低的门槛用来阻止广告的。入群的验证暗号是:我爱编译原理
题意理解
这不就是随便写吗?没有任何问题的。代码
#include <cstring> #include <iostream> #include <cmath> #include <stdio.h> #include <stdlib.h> #include <string> #include <iomanip> #include <vector> using namespace std; void read(int &x) { x = 0; int f = 1; char ch = getchar(); while(ch > '9'||ch < '0') { if(ch == '-') { f = -1; } ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + (int)(ch - 48); ch = getchar(); } x = x * f; } bool visited[10]; void init() { memset(visited, 0, sizeof visited); } bool is_valid() { for(int i = 1; i <= 9; i++) { if(!visited[i]) { return false; } } return true; } void visit(int x) { visited[x / 100] = true; visited[x / 10 % 10] = true; visited[x % 10] = true; } int main() { int a, b, c; read(a); read(b); read(c); bool has_result = false; for(int i = 100; i <= 333; i++) { init(); if(i / a * a != i) { continue; } if(i / a * c >= 1000) { continue; } visit(i); visit(i / a * b); visit(i / a * c); if(is_valid()) { printf("%d %d %d\n", i, i / a * b, i / a * c); has_result = true; } } if(!has_result) { printf("No!!!"); } return 0; }
欢迎加入“不会算法一群菜鸟”,群号是⑥⑥①⑨②2025,这是我设置的一道很低的门槛用来阻止广告的。入群的验证暗号是:我爱编译原理
相关文章推荐
- 洛谷-三连击(升级版)-BOSS战-入门综合练习1
- 新手村 Boss战-入门综合练习1 陶陶摘苹果(升级版)
- 新手村 Boss战-入门综合练习1 哥德巴赫猜想(升级版)
- 新手村 Boss战-入门综合练习1 烤鸡
- 新手村 Boss战-入门综合练习2 Cantor表
- 洛谷-哥德巴赫猜想(升级版)-BOSS战-入门综合练习1
- 洛谷-陶陶摘苹果(升级版)-BOSS战-入门综合练习1
- 新手村 Boss战-入门综合练习2 小鱼会有危险吗
- 新手村之BOSS战-入门综合练习1
- 新手村之BOSS战-入门综合练习2
- 新手村 Boss站-入门综合练习2 Function
- GDI+入门(6、综合练习)
- .NET入门(十)综合练习一,键盘读取,转换,循环输出
- C语言编程入门——综合练习(二)
- UFT入门教程(4)—综合练习一
- 普及练习场 BOSS战-普及综合练习1 幻想迷宫
- 洛谷-小鱼会有危险吗-BOSS战-入门综合练习2
- C语言编程入门——综合练习(三)学生管理系统
- 35、Java入门—网络编程之综合练习
- 慕课网JAVA入门第二季综合练习答答租车系统