hdu 1664 Different Digits, spoj 3929 , 同余,bfs

Zemax 中的 LED 阵列模型 这些光线是所有光线的子集,用于布局可视化,而不是详细分析。X 和 Y 散度(αx 和 αy)以度为单位,以不同的方式设置为 6 度和 12 度。每个 LED 都以朗伯模式(广角分布)发光,尽管有些 LED 具有内置光学元件,用于更窄或更聚焦的光束。,具体取决于这些类别中使用的半导体材料。LED 阵列由多个发光二极管 (LED) 组成,这些二极管以特定模式或配置排列,以实现均匀照明、更高强度或特定照明特性。如果数据的存在更改为“辐射强度”,则它以弧度为单位显示每个立体角的功率,作为探测器上入射角的函数。 阅读详情

Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 820    Accepted Submission(s):
 202

Problem Description
Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decimal. For example, number 1334 contains three different digits 1, 3 and 4.
 

Input
The input consists of no more than 50 test cases. Each test case has only one line, which contains a positive integer n ( 1<=n < 65536). There are no blank lines between cases. A line with a single `0' terminates the input.
 

Output
For each test case, you should output one line, which contains m. If there are several possible results, you should output the smallest one. Do not output blank lines between cases.
 

Sample Input
7 15 16 101 0
 

Sample Output
7 555 16 1111


题意:

给一个n,让你找出含不同数字最少的n的倍数,如果含不同数字相同,则输出最小的。


同余,bfs


定理:
对于任意的整数n,必然存在一个由不多于两个的数来组成的一个倍数。
因为a,aa,aaa……取n+1个,则必有两个模n余数相同,相减即得n的倍数m。而m只由a、0组成。




#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <queue>
#include <string>
using namespace std;

const int maxn = 100000;
int N;
int a[5], cnt;
string ans;
int ansn;
struct node{
	short d;
	int pre;
	int re;
};
node q[maxn];
int head, tail;

string tmp;

inline int cmpstr(string a, string b){
	if( a.size()<b.size() || (a.size()==b.size()&&a<b) )
		return -1;
	return 1;
}
bool hash[70000];
bool bfs(){
	head = tail = 0;
	node nt, qt;
	memset(hash, 0, sizeof hash );
	for(int i=0; i<cnt; ++i){
		if(a[i]==0) continue;
		nt.d = a[i];
		nt.pre = -1;
		nt.re = a[i] % N;
		q[tail++] = nt;
		hash[nt.re] = 1;
	}
	while(head<tail){
		nt = q[head];
		for(int i=0; i<cnt; ++i){
			qt.d = a[i]; qt.pre = head; qt.re = (nt.re*10+a[i]) % N;
			if(!hash[qt.re]){
				hash[qt.re] = 1;
				q[tail++] = qt;
			}
			if(qt.re==0){
				tmp = "";
				for(int pos=tail-1; pos!=-1; pos = q[pos].pre){
                    tmp += q[pos].d + '0';
				}
				reverse(tmp.begin(), tmp.end());
				return 1;
			}
		}
		head++;
	}
	return 0;
}

void solve(int N){
	set<int> st;
	ans = "";
	for(int x=N, y; x>0; x/=10){
		y = x % 10;
		ans += y + '0';
		st.insert(y);
	}
	ansn = st.size();
	reverse(ans.begin(), ans.end());
	cnt = 1;
	for(a[0]=1; a[0]<10; ++a[0]){
        if(bfs())
        if(ansn>cnt || (ansn==cnt&&cmpstr(tmp,ans)<0) ){
            ans = tmp;
            ansn = cnt;
        }
	}
	if(ansn==cnt){
        printf("%s\n", ans.c_str());
        return ;
	}
	cnt = 2;
	for(a[0]=0; a[0]<10; ++a[0]){
		for(a[1]=a[0]+1; a[1]<10; ++a[1]){
		   if(bfs())
           if(ansn>cnt ||(ansn==cnt&&cmpstr(tmp,ans)<0)){
                ans = tmp;
                ansn = cnt;
           }
		}
	}
	printf("%s\n", ans.c_str());
}

template<class T>
inline bool scan_d(T &ret){
    char c; ret = 0;
    while((c=getchar())<'0'||c>'9');
    while(c>='0'&&c<='9') ret = ret*10 + (c-'0'),c=getchar();
    return 0;
}
int main(){
   // freopen("in.txt","r",stdin);
	while(true){
        scan_d(N);
		if(N==0) break;
		if(N<10){
			printf("%d\n", N);
			continue;
		}
		solve(N);
	}
	return 0;
}






HWSD全球土壤数据下载、处理与提取完整指南 全球尺度的科学研究与工程项目中,土壤数据是必不可少的基础底图,而HWSD(和谐世界土壤数据库)凭借其统一的分辨率与属性标准,成为农业区划、生态模型、土地利用变化和水资源评估等领域的通用数据源。深入理解其“栅格存编号、数据库存属性”的核心原理,是高效使用这套数据的关键。通过掌握MDB数据库结构、属性字段含义以及栅格与属性表的关联方法,研究者可以将原始数据转化为可用的研究底图。无论你是需要提取特定区域的土壤属性,还是进行面积统计与点位采样,合理的处理流程都能显著提升工作效率。本文从下载注册开始,一步步梳理数据清 阅读详情

相关推荐

cst使用局部网格加密,手动加密,special设置等方法合理网格布局加速仿真速度

在CST中,计算复杂模型或者阵列的时候往往需要耗费大量仿真时间,除了使用更高性能的电脑或工作站进行仿真,合理对CST的仿真网格进行适当设置也是必不可少的一步。CST中网格设置影响模拟的精度和速度,因此花时间理解网格过程是很重要的。

OVEN_b612的博客 1万+

HDU-1664-Different Digits(BFS)

Problem Description Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decim

青春无悔 1052

项目过程记录:ADS-B信号接收并显示(Ubuntu20.04+ANTSDR E310V2)

最近被安排做一个ADS-B信号接收的项目,拿到软件无线电模块(ANTSDR E310V2)后安装环境和软件真的太折磨了。。在此记录以下我走过的弯路,大家可以参考一下。

weixin_43627638的博客 5026

【hdu】1664 different digits【搜索+字符串处理】

题意: 找出给出数的倍数中组成数字最少的那个数,如果组成数字一样输出大小最小的那个数 题解: 刚看到的时候不知所措,根本不知道哪里可以剪枝,也不知道搜索到哪里为止。。。。 point1:该题用到了数论的知识:对于任意的整数n,必然存在一个由不多于两个的数来组成的一个倍数。所以先搜1个数的再搜2个数的就好 证明:因为 a , aa , aaa…… 取 n+1 个,则由鸽笼原理,必有两个模

a709743744的博客 526

从零构建2.4G无线通信系统:MSPM0G3507与NRF24L01的深度协同设计

本文详细介绍了基于MSPM0G3507微控制器与NRF24L01射频模块构建2.4G无线通信系统的深度协同设计方案。内容涵盖系统架构、SPI通信优化、功耗管理、抗干扰机制及中断/DMA高效利用,为工业物联网应用提供高可靠、低功耗的无线传输解决方案。

rice5的博客 827

别再搞混了!MATLAB通信仿真中EbN0转SNR的保姆级公式推导与避坑指南

本文深入解析MATLAB通信仿真中EbN0与SNR转换的核心公式,揭示数字仿真与理论系统的关键差异。通过真实案例展示错误参数设置导致的隐蔽问题,并提供完整的参数自查清单和正确实现代码,帮助工程师和学生避免常见错误,确保仿真结果准确可靠。

weixin_28746223的博客 352

【POJ 2283】 【HDU 1664】 Different Digits

Description Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decimal. Fo

HHH的专栏 706

经典脉冲激光测距原理&雷达方程

脉冲激光测距机的工作过程如下:首先用瞄准光学系统瞄准目标,然后接通激光电源,储能电容器充电,产生触发闪光灯的触发脉冲,闪光灯点亮,激光器受激辐射,从输出反射镜发射出一个前沿陡峭、峰值功率高的激光脉冲,通过发射光学系统压缩光束发射角后射向目标。通过计算激光发射功率经介质传输的衰减,目标表面截获和反射的光功率,到达接收视场的光功率,以及接收光学系统接收到的光功率,就可以得到到达光电探测器的光功率,即接收功率。⑤光東路程上的折射率变化;),测量光脉冲到达目标并由目标返回到接收机的时间,由此计算出目标的距离。

weixin_46153372的博客 2546

Given a positive integer N, you should output the most right digit of N^N.

Problem Description Given a positive integer N, you should output the most right digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T which

残云墨雪 6636

Qwen 三代进化全景对比:从 Qwen2.5 到 Qwen3 再到 Qwen3.5

本文对比了阿里巴巴通义千问三代大模型(Qwen2.5、Qwen3、Qwen3.5)的技术演进。18个月内,模型在架构、训练数据和能力上实现显著突破:从纯稠密结构(Qwen2.5)发展为混合注意力架构(Qwen3.5),支持语言从29种扩展至201种,并实现原生多模态融合。关键进展包括引入MoE架构、Gated DeltaNet混合注意力机制(计算效率提升10倍)、以及从独立模态到早期视觉语言联合训练的转变。模型阵容从7个通用尺寸发展为8+个混合架构,最大参数量达397B,上下文窗口扩展至256K(托管版1M

m0_47999117的博客 1万+

uni-app蓝牙MTU设置失效探因:从20字节限制到跨设备兼容性实战

本文深入探讨了uni-app蓝牙开发中MTU设置失效的常见问题,特别是20字节限制的成因及解决方案。通过分析设备兼容性、蓝牙协议栈特性和系统版本差异,提供了智能延迟策略、设备特征检测和渐进式MTU提升等实战方案,帮助开发者优化蓝牙数据传输效率。

weixin_29289821的博客 295

Your task is to find for a given phone number any of its divisions into groups of two or three digit

D - Phone numbers 代码:Happy-训练6-Dimport java.util.Scanner;public class Main { public static void main(String[] args){    int n,i=0,m=1;    Scanner scan=new Scanner(System.in);    n=scan.nextInt();   ...

L427630的博客 455

本地Pycharm连接远程服务器详细配置过程(直接在本地使用服务器显卡,很棒)

相信很多人都遇见过这种情况:实验室成员使用同一台服务器,每个人拥有自己的独立账号,我们可以使用服务器更好的配置完成实验,毕竟自己哪有money拥有自己的3090呢。

NorthSmile的博客 4万+

HDU1664 Different Digits(bfs +数论剪枝)

欢迎参加——每周六晚的BestCoder(有米!) Different Digits Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1129 Accepted Submission(s): 290Problem Descri

qwesde 1171

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

HDOJ 1664 Different digits

Problem Description Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decim

cecil203的博客 489

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

hdu 1664 Different Digits (bfs+取余判重+数论知识)

Different Digits Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 382    Accepted Submission(s): 90 Problem Description Given a pos

To be what you what to be! 2433

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

hdu 1664 Different Digits(bfs+余数判重)

Problem Description Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in dec

小张的专栏 743

poj1426 Find The Multiple(哈夫曼思想)

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there

芒果街上的小屋(此博客暂时停用) 2083

A*算法入门

原作者文章链接:http://www.policyalmanac.org/games/aStarTutorial.htm 启发式搜索:启发式搜索就是在状态空间中的搜索对每一个搜索的位置进行评估,得到最好的位置,再从这个位置进行搜索直到目标。这样可以省略大量无畏的搜索路径,提到了效率。在启发式搜索中,对位置的估价是十分重要的。采用了不同的估价可以有不同的效果。 估价函数:从当前节点移

天亮说晚安 6465

hdu1043 Eight (八数码问题,多种解法)

hdu1043 :http://acm.hdu.edu.cn/showproblem.php?pid=1043 八数码问题       有一个3*3的棋盘,其中有0-8共9个数字,0表示空格,其他的数字可以和0交换位置。求由初始状态到达目标状态 123  456  780 的步数最少的解? 有多组数据 解法: 1、反向BFS + hash( cantor展开 ) 因为状态总

天亮说晚安 4411

POJ1729 Jack and Jill (双向广度优先搜索, DBFS)

loading

天亮说晚安 3543

hdu 5113 Black And White, 黑白染色,技巧

Black And White Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 485    Accepted Submission(s): 131 Special Judge Problem Description

天亮说晚安 3148

搜索练习题集

http://www.cnblogs.com/ambition/archive/2011/07/25/search_plus.html   HDU3663 搜索,DLX http://blog.csdn.net/yihuikang/article/details/8092172 HDU4778 搜索,alpha-beta http://blog.csdn.net/waitfor_/a

天亮说晚安 3121

poj 1564 Sum It Up | zoj 1711 | hdu 1548 (dfs + 剪枝 or 判重)

Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Fo

天亮说晚安 2679

hdu1242 Rescue(BFS +优先队列 or BFS )

http://acm.hdu.edu.cn/showproblem.php?pid=1242 题意:     Angel被传说中神秘的邪恶的Moligpy人抓住了!他被关在一个迷宫中。迷宫的长、宽不超过200。 迷宫中有不可以越过的墙以及监狱的看守。  Angel的朋友带了一些救援队来到了迷宫中。他们的任务是:接近Angel。我们假设接近Angel就是到达Angel所在的位置。 假设移

天亮说晚安 2643

hdu 2616 Kill the monster(深搜)

http://acm.hdu.edu.cn/showproblem.php?pid=2616 题意: 有n种技能,每种技能只能用一次,怪物有m点血,问最少需要多少种技能可以把怪物杀死。 每种技能有两个数值a和b,a表示攻击力,b表示当怪物的血量小于等于b时,这种技能的攻击力可以变为2a。 一点攻击力可以杀掉怪物一点血。             简单深搜

天亮说晚安 2447
上一篇: zoj 3836 Circulation pipe , exgcd
下一篇: SPOJ 12943. Counting, dp ,巧妙
yew1eb
博客等级 码龄14年 148粉丝 378原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值