当前位置:网站首页>[exercise-6] (UVA 725) division = = violence
[exercise-6] (UVA 725) division = = violence
2022-07-06 15:56:00 【Flame car】
translate :
Enter a positive integer n, Output all shapes from small to large, such as abcde/fghij=n The expression of , among a~j Exactly a number 0 ~9 An arrangement of ( There can be leads 0),2≤n≤79
This question is not difficult , I think it's interesting , So write casually .
AC Code :
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll mod = 1e9+7;
int num[20];
bool solve(int x1,int x2){
memset(num,0,sizeof num);
if(x2>98765)
return 0;
for(int i=0;i<5;i++)// Count
num[x1%10]++,num[x2%10]++,x1/=10,x2/=10;
for(int i=0;i<=9;i++)// Judge whether it is a 0~9 An arrangement of
if(num[i]!=1)
return 0;
return 1;
}
int main()
{
int n,cnt=0;
while(cin>>n && n)
{
int flag = 1;
for(int i=1234;i<=98765;i++)
{
if(solve(i,i*n))
{
flag = 0;
printf("%05d / %05d = %d\n",n*i,i,n);
}
}
if(flag)
printf("There are no solutions for %d.\n",n);
cout<<endl;
}
}
So why is it written like this ? First, let's write the formula in this form A / B = C, Then it can be simplified into ,A = B * C. and C We know this time , As long as we enumerate B That is, the denominator , Also can put the A Show it .
So the idea is very clear , enumeration B( One ), And then use B Multiply what you already know C, obtain A( Two ). Judge A and B Is it right? 0~9 Just sort all the numbers !
The judgment is simple. Just make a cycle , And we know B * C That is to say A It can't be greater than 98765 Of , This can also be used as a termination condition .
边栏推荐
- Information security - threat detection - detailed design of NAT log access threat detection platform
- 编程到底难在哪里?
- Opencv learning log 19 skin grinding
- Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
- Accounting regulations and professional ethics [2]
- MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
- Learning record: STM32F103 clock system overview working principle
- Gartner: five suggestions on best practices for zero trust network access
- China's peripheral catheter market trend report, technological innovation and market forecast
- China chart recorder market trend report, technology dynamic innovation and market forecast
猜你喜欢

渗透测试 ( 8 ) --- Burp Suite Pro 官方文档

Gartner:关于零信任网络访问最佳实践的五个建议

基于web的照片数码冲印网站

【高老师UML软件建模基础】20级云班课习题答案合集

渗透测试 ( 3 ) --- Metasploit Framework ( MSF )

Learning record: understand systick system timer and write delay function

Information security - Analysis of security orchestration automation and response (soar) technology
![[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class](/img/3b/dc43564a36f82e73826b08f39c935e.png)
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class

1010 things that college students majoring in it must do before graduation

Ball Dropping
随机推荐
差分(一维,二维,三维) 蓝桥杯三体攻击
Report on the market trend, technological innovation and market forecast of printing and decorative paper in China
nodejs爬虫
Nodejs+vue online fresh flower shop sales information system express+mysql
【练习-11】4 Values whose Sum is 0(和为0的4个值)
HDU-6025-Coprime Sequence(女生赛)
【练习-4】(Uva 11988)Broken Keyboard(破损的键盘) ==(链表)
Gartner:关于零信任网络访问最佳实践的五个建议
Information security - security professional name | CVE | rce | POC | Vul | 0day
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
程序员的你,有哪些炫技的代码写法?
Alice and Bob (2021牛客暑期多校训练营1)
Learning record: understand systick system timer and write delay function
China's earthwork equipment market trend report, technical dynamic innovation and market forecast
CEP used by Flink
Nodejs+vue网上鲜花店销售信息系统express+mysql
Accounting regulations and professional ethics [3]
D - Function(HDU - 6546)女生赛
【练习-7】Crossword Answers