当前位置: 首页 > news >正文

【P1008 [NOIP1998 普及组] 三连击】

[NOIP1998 普及组] 三连击

题目背景

本题为提交答案题,您可以写程序或手算在本机上算出答案后,直接提交答案文本,也可提交答案生成程序。

题目描述

1 , 2 , … , 9 1, 2, \ldots , 9 1,2,,9 9 9 9 个数分成 3 3 3 组,分别组成 3 3 3 个三位数,且使这 3 3 3 个三位数构成 1 : 2 : 3 1 : 2 : 3 1:2:3 的比例,试求出所有满足条件的 3 3 3 个三位数。

输入格式

输出格式

若干行,每行 3 3 3 个数字。按照每行第 1 1 1 个数字升序排列。

样例 #1

样例输入 #1

样例输出 #1

192 384 576
* * *
...* * *
(剩余部分不予展示)

代码如下:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<istream>
#include<iomanip>
#include<ostream>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<fstream>
#include<stack>
#include<ctime>
#include<deque>
#include<queue>
#include <sstream>
#include <numeric>
#include <sstream>#pragma warning (disable:4996)int temp;
using namespace std;int fun(int a,int b,int c)
{int flag[10] = { 0 };while (a > 0){temp = a % 10;flag[temp] = 1;a /= 10;}while (b > 0){temp = b % 10;flag[temp] = 1;b /= 10;}while (c > 0){temp = c % 10;flag[temp] = 1;c /= 10;}if (flag[0] == 1)return 0;for (int i = 1; i <= 9; i++){if (flag[i] == 0)return 0;}return 1;
}int main() {int x;for(int i=1;i<=3;i++){for (int j = 1; j <= 9; j++) {for (int k = 1; k <= 9; k++) {if (i != j && i != k && j != k) {x=i * 100 + j * 10 + k;if (x * 2 <= 999) {if (x * 3 <= 999) {if (fun(x, x * 2, x * 3)==1)cout << x << " " << x * 2 << " " << x * 3 << endl;}}}}}}}
http://www.lryc.cn/news/234343.html

相关文章:

  • 机器学习算法——集成学习
  • java springboot在当前测试类中添加临时属性 不影响application和其他范围
  • 原型网络Prototypical Network的python代码逐行解释,新手小白也可学会!!由于工作量大,准备整8个系列完事,-----系列5
  • milvus数据库的数据管理-插入数据
  • 系列一、请谈谈你对JVM的理解?Java8的虚拟机有什么更新?
  • 恕我直言,大模型对齐可能无法解决安全问题,我们都被表象误导了
  • Apache Airflow (九) :Airflow Operators及案例之BashOperator及调度Shell命令及脚本
  • IJ中配置TortoiseSVN插件:
  • 个人实现在线支付,一种另类的在线支付解决方案
  • 浅谈智能安全配电装置应用在银行配电系统中
  • macOS下如何使用Flask进行开发
  • 记一次服务器配置文件获取OSS
  • 合众汽车选用风河Wind River Linux系统
  • PTA平台-2023年软件设计综合实践_5(指针及引用)
  • 智慧卫生间
  • Cadence virtuoso drc lvs pex 无法输入
  • 反序列化漏洞(2), 分析调用链, 编写POC
  • Pytorch reshape用法
  • Latex 辅助写作工具
  • frp新版本frp_0.52.3设置
  • 100G.的DDoS高防够用吗?
  • 【django+vue】项目搭建、解决跨域访问
  • 【数据库】数据库连接池导致系统吞吐量上不去-复盘
  • 华纳云:租用的服务器连接超时怎么办?
  • 基于MS16F3211芯片的触摸控制灯的状态变化和亮度控制(11.17,PWM)
  • 编译buildroot出错,这个怎么解决呢,感谢
  • 【0基础学Java第十课】-- 认识String类
  • lxml基本使用
  • 【数据结构初阶】链表OJ
  • 【Vue渲染】 条件渲染 | v-if | v-show | 列表渲染 | v-for