CodeForces 149B - Martian Clock

SIwave学习记录:电热耦合仿真 SIwave电热耦合仿真 阅读详情

B. Martian Clock
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfair to Petya as he adored adventure stories that featured lasers and robots.

Today Petya is watching a shocking blockbuster about the Martians called "R2:D2". What can "R2:D2" possibly mean? It might be the Martian time represented in the Martian numeral system. Petya knows that time on Mars is counted just like on the Earth (that is, there are 24 hours and each hour has 60 minutes). The time is written as "a:b", where the string a stands for the number of hours (from 0 to23 inclusive), and string b stands for the number of minutes (from 0 to 59 inclusive). The only thing Petya doesn't know is in what numeral system the Martian time is written.

Your task is to print the radixes of all numeral system which can contain the time "a:b".

Input

The first line contains a single string as "a:b" (without the quotes). There a is a non-empty string, consisting of numbers and uppercase Latin letters. String a shows the number of hours. String b is a non-empty string that consists of numbers and uppercase Latin letters. String b shows the number of minutes. The lengths of strings a and b are from 1 to 5 characters, inclusive. Please note that strings aand b can have leading zeroes that do not influence the result in any way (for example, string "008:1" in decimal notation denotes correctly written time).

We consider characters 0, 1, ..., 9 as denoting the corresponding digits of the number's representation in some numeral system, and characters A, B, ..., Z correspond to numbers 10, 11, ..., 35.

Output

Print the radixes of the numeral systems that can represent the time "a:b" in the increasing order. Separate the numbers with spaces or line breaks. If there is no numeral system that can represent time "a:b", print the single integer 0. If there are infinitely many numeral systems that can represent the time "a:b", print the single integer -1.

Note that on Mars any positional numeral systems with positive radix strictly larger than one are possible.

Sample test(s)
input
11:20
output
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
input
2A:13
output
0
input
000B:00001
output
-1
Note

Let's consider the first sample. String "11:20" can be perceived, for example, as time 4:6, represented in the ternary numeral system or as time 17:32 in hexadecimal system.

Let's consider the second sample test. String "2A:13" can't be perceived as correct time in any notation. For example, let's take the base-11 numeral notation. There the given string represents time 32:14 that isn't a correct time.

Let's consider the third sample. String "000B:00001" can be perceived as a correct time in the infinite number of numeral systems. If you need an example, you can take any numeral system with radix no less than 12.



===========================

题目问的就是a:b形式的时间在哪几种进制下a b能满足 在十进制下a属于[0,23],b属于[0,59]


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

char str[22];
int j=0,k=0,p,a[11],b[11];

bool check(int x)
{
    //cout<<"x="<<x<<endl;
    int suma=0,sumb=0;
    for(int i=0;i<j;i++) if(a[i]>=x) return 0;
    for(int i=0;i<k;i++) if(b[i]>=x) return 0;
    for(int i=0;i<j;i++)
    {
        int temp=1;
        for(int ii=i+1;ii<j;ii++)
        {
            temp*=x;
        }
        suma+=a[i]*temp;
        //cout<<"suma="<<suma<<endl;
        if(suma>=24) return 0;
    }
    for(int i=0;i<k;i++)
    {
        int temp=1;
        for(int ii=i+1;ii<k;ii++)
        {
            temp*=x;
        }
        sumb+=b[i]*temp;
        //cout<<"sumb="<<sumb<<endl;
        if(sumb>=60) return 0;
    }
    return 1;
}

int main()
{
    int ok=0,flag=0;
    cin>>str;
    for(int i=0;i<strlen(str);i++)
        if(str[i]==':')
            p=i;
    for(int i=0;i<p;i++)
    {
        while(str[i]=='0'&&!flag) i++;
        if(i==p) break;
        flag=1;
        if(str[i]>='A'&&str[i]<='Z') a[j]=str[i]-'A'+10;
        else a[j]=str[i]-'0';
        j++;
    }
    flag=0;
    for(int i=p+1;i<strlen(str);i++)
    {
        while(str[i]=='0'&&!flag) i++;
        if(i==p) break;
        flag=1;
        if(str[i]>='A'&&str[i]<='Z') b[k]=str[i]-'A'+10;
        else b[k]=str[i]-'0';
        k++;
    }
    /*for(int i=0;i<j;i++) cout<<a[i];
    cout<<endl;
    for(int i=0;i<k;i++) cout<<b[i];
    cout<<endl;*/
    if((j==0||(j==1&&a[0]<24))&&(k==0||k==1))
    {
        cout<<"-1"<<endl;
        ok=1;
    }
    else
    {
        for(int i=2;i<=60;i++)
        {
            if(check(i))
            {
                ok=1;
                cout<<i<<" ";
            }
        }
        if(ok) cout<<endl;
    }
    if(!ok) cout<<"0"<<endl;
    return 0;
}


HFSS本征模求解:谐振特性分析与工程实践 本征模求解是电磁仿真中的基础技术,用于分析无源谐振系统的固有特性。其核心原理是通过求解麦克斯韦方程组的特征值问题,获得谐振频率、品质因数(Q值)及电磁场分布等关键参数。在5G滤波器设计、雷达谐振腔优化等高频场景中,精确的本征模分析能有效避免模式干扰,提升器件性能。HFSS作为行业标准工具,提供了完整的本征模求解工作流,涵盖边界条件设置、模式识别、场分布可视化等关键环节。针对多模耦合、模式纯度评估等工程难题,结合参数化扫描和场重叠积分等高级技巧,可显著提升微波器件设计效率。 阅读详情

相关推荐

字符串替换—牛客网(C++实现)

一.题目描述 请你实现一个简单的字符串替换函数。原串中需要替换的占位符为"%s",请按照参数列表的顺序一一替换占位符。若参数列表的字符数大于占位符个数。则将剩下的参数字符添加到字符串的结尾。 给定一个字符串A,同时给定它的长度n及参数字符数组arg,请返回替换后的字符串。保证参数个数大于等于占位符个数。保证原串由大小写英文字母组成,同时长度小于等于500。 测试样例: “A%sC%sE”,7,[‘...

qq_38358582的博客 1522

CodeForces - 149B Martian Clock

B. Martian Clock time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Having stayed home alone, Petya decided to watch forbidden film...

Lngxling的博客 359

五分钟搞懂游戏开发中的抗锯齿算法

常见抗锯齿算法总结锯齿由来抗锯齿算法SSAAMSAACSAA 锯齿由来 场景的定义在三维空间中是连续的,而最终显示的像素则是一个离散的二维数组,这是计算机屏幕产生锯齿的原因。在计算机处理图形的过程中(渲染管线了解一下),有一个非常重要的阶段,就是光栅化,光栅化主要的作用是将顶点数据的不连续性通过插值计算,将两个顶点之间不存在的点进行弥补,然后实现到屏幕像素点上的一一映射。如图,现在要在屏幕上绘制一...

绿洲守望者 1万+

Codeforces 898D Alarm Clock (贪心好题)

  D. Alarm Clock time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Every evening Vitalya sets n alarm clocks to wake up tomorrow. ...

知与谁i的博客 1147

深入AutoSar诊断协议栈:当ECU报故障时,FiM模块是如何悄悄“阉割”功能的?

本文深入解析AutoSar诊断协议栈中FiM模块的工作原理,揭示ECU报故障时如何通过Inhibition Counter和位运算技术实现功能静默降级。探讨FiM在故障处理链中的关键角色,包括功能权限仲裁、降级策略执行和系统安全兜底,并分享实战调试技巧与进阶应用案例。

weixin_30673611的博客 174

Edge浏览器IE模式全攻略:从企业应用到老旧网站兼容(含常见问题解答)

本文详细解析了微软Edge浏览器的IE模式,这是解决企业遗留系统与老旧网站兼容性问题的关键技术。文章从核心原理出发,提供了从个人用户临时启用到企业级组策略部署的完整配置指南,并深入探讨了文档模式调优、ActiveX控件处理等高级技巧,最后汇总了常见问题排查与安全实践,帮助用户高效平衡兼容性与现代化浏览体验。

weixin_29227425的博客 609

Codeforces Round #106

  B.Martian_Clock   容易犯错的地方是判断无解的情况, 如果只有1位数(一个字母或者一个数字)则无解,但是无解有可能需要输出-1或者0,需要更加精确地判断.    关键代码 if(lenh-ph<=1 && lenm-pm<=1) { if(hour[ph]>='O' && hour...

weixin_30734435的博客 277

vivado Block Design 设计 .tcl 文件使用,导出,修改,添加方式

在vivado中生成 Block Design可以导出tcl文件进行保存(体积小),或者在别的版本vivado中打开(版本互通),这是一个非常好的功能。另外GitHub中很多项目都是采用这种方式上传的,学会如何使用可以快速修改历程项目。

2203_75345038的博客 2494

codeforces 149B-Move and Turn

import java.util.*; public class Main{ static Scanner sc=new Scanner(System.in); static int t,n; public static void main(String []args) { n=sc.nextInt(); if(n%2==1){ /*n=2k+1奇数时,从水平一步开始,总共有k+1水平步骤和k垂直步骤,所以组合个数为(k+1)*

dregs_的博客 258

MT4/MT5数据源接入全攻略:从买服务、自研API到低成本DDE,哪种方案适合你?

本文全面解析MT4/MT5数据源接入的三种主流方案:商业服务、自研API和低成本DDE,详细对比其技术参数、成本结构和适用场景。帮助技术团队根据业务需求选择最优方案,确保外汇交易系统的数据流稳定性和实时性,提升交易体验和业务连续性。

weixin_42568801的博客 172

dolphinscheduler-3.4.0

dolphinscheduler集群部署

docsz的博客 660

cfB. Luba And The Ticket time limit per test2 seconds memory limit per test256 megabytes inputstanda

B. Luba And The Ticket time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Luba has a ticket consisting of 6 di

Dosth_Magic 5068

板蓝根挥发油微胶囊化技术及其在抗菌织物整理中的应用研究

微胶囊技术是一种通过成膜材料将具有反应活性或挥发性的液体或固体包封成微小颗粒的技术。该技术因其优异的缓释保护和物态改变性能,已在医药、食品、化妆品等多个领域得到广泛应用。本研究采用复凝聚法制备板蓝根挥发油的微胶囊,利用明胶和阿拉伯胶作为壁材,旨在提升其稳定性和抗菌性能。

qq_62634009的博客 584

Codeforces 149B Martian Clock【模拟】

B. Martian Clock time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Having stayed home alone, Petya decided to

世界很大 637

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

CodeForces - 149B Martian Clock (模拟进制)

题目链接:http://codeforces.com/problemset/problem/149/B点击打开链接 B. Martian Clock time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st

xuejye的博客 276

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

time limit per test/memory limit per test

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4

qq_44470353的博客 1291

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

CodeForces-89D:Space mines(思维)

CodeForces-89D:Space minesOnce upon a time in the galaxy of far, far away... Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star. When the rebel

Mitsuha_的博客 773

CodeForces 165C - Another Problem on Strings

C. Another Problem on Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A string is binary, if it con

coco430的专栏 1270

CodeForces 165B - Burning Midnight Oil(二分)

B. Burning Midnight Oil time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day a highly important task was

coco430的专栏 1074

CodeForces 160B - Unlucky Ticket

B. Unlucky Ticket time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each of you probably has your personal ex

coco430的专栏 947

CodeForces 204B - Little Elephant and Cards

B. Little Elephant and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves to play with c

coco430的专栏 944

CodeForces 141B - Hopscotch

B. Hopscotch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output So nearly half of the winter is over and Maria

coco430的专栏 929

CodeForces 149C - Division into Teams(贪心)

C. Division into Teams time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves football very much, espe

coco430的专栏 917

CodeForces 148C - Terse princess

C. Terse princess time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «Next please», — the princess called and

coco430的专栏 765

CodeForces 148B - Escape

B. Escape time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The princess is going to escape the dragon's cave

coco430的专栏 749

CodeForces 155B - Combination(贪心)

B. Combination time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya plays a card game by the following rule

coco430的专栏 747
上一篇: CodeForces 148C - Terse princess
下一篇: CodeForces 151B - Phone Numbers
coco430
博客等级 码龄14年 9粉丝 107原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值