poj 3331 The Idiot of the Year Contest!

TNS-12516及ORA-12516错误解决 在客户端进行sqlplus连接报错如下: ORA-12516: TNS: 监听程序找不到符合协议堆栈要求的可用处理程序 在/home/oracle/product/10.2.0/db_1/network/log/listener.log中查看到错误如下: TNS-12516: TNS:listener could not find available handler with matchin 阅读详情

The Idiot of the Year Contest!
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 3744 Accepted: 1952

Description

There is just one basic rule in the Idiot of the Year Contest (IYC)! The contestant picks a random digit between 0 and 9, computes the factorial of the day of the year he/she is born, and counts the how many times the digit picked appears in the factorial. The contestant with highest count is the Idiot of the Year! For example, if you are born on 5th of Mordad which is the 129th day of the year, and you pick the digit 6, your score will be the number of times the digit 6 appears in 129! (that is 1 × 2 × 3 × ... × 129).

The chief judge of IYC wants you to write a program to get an integer which is the day of the year a contestant is born on and a digit and report the number of times the digit appears in the factorial of the first number.

Input

The first line of the input contains a single integer T which is the number of test cases, followed by T lines each containing the data for a test case having two numbers. The first number is the day of the year a contestant is born and the second one is the digit he/she has picked.

Output

The output contains T lines, each having one integer which is the number of times the digit appears in the factorial of the first number.

Sample Input

2
5 2
7 0

Sample Output

1
2 

题意:求n!中含有x的数量;

#include <iostream>
#include <string.h>
using namespace std;
int a[1005];
void mul(int n){
	int left=0;
	for (int i=0;i<1000;i++){
		a[i]=left+a[i]*n;
		left=a[i]/10;
		a[i]%=10;
	}
}
int main(){
	int t,n,x;
	cin>>t;
	while(t--){
		cin>>n>>x;
		memset(a,0,sizeof(a));
		a[0]=1;
		for (int i=2;i<=n;i++){
			mul(i);
		}
		int k=1000;
		
		for (;k>=0;--k){
			if (a[k])
				break;
		}

		int count=0;
		for (int i=0;i<=k;i++){
			if (a[i]==x)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}



MATLAB和S7-1200PLC水箱液位高度PID控制联合仿真(KEPserverOPC通信应用) SMART PLC 向导PID的详细介绍请查看下面文章链接:S7-200 SMART PLC PID向导详细介绍(如何实现P、PD、PID控制器)-优快云博客文章浏览阅读1k次。这篇博客主要介绍SMART PLC PID向导的使用,PID控制相关的其它内容请查看专栏系列文章,常用链接如下:SMART PLC PID负压控制(过程量为负数)_负压控制pid控制程序_RXXW_Dor的博客-优快云博客1、如何实现PID反作用调节?S7-1200PLC和KEPserver OPC通信-优快云博客。 阅读详情

相关推荐

74HC165级联踩坑实录:STM32读取32路开关状态,时序调试与常见问题排查

本文详细介绍了74HC165级联在STM32读取32路开关状态时的时序调试与常见问题排查。从硬件设计的PCB布局优化、电源噪声控制,到软件时序的精确调校和数据采集策略,提供了完整的解决方案。通过逻辑分析仪和示波器的高效使用,解决了信号延迟和干扰问题,最终实现了稳定可靠的32路信号读取。

weixin_34046298的博客 313

poj3331

The Idiot of the Year Contest! Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3492   Accepted: 1829 Description There is just one basic rule in the Idiot

◆◇丶生如夏花。谁来订阅我的悲伤 486

攻克JESD204B多ADC同步:从时钟对齐到数据对齐的实战解析

本文深入解析了JESD204B多ADC同步的系统性挑战与实战解决方案。从确保设备时钟同源、精确捕获SYSREF信号,到管理接收端弹性缓冲区与释放点,文章提供了从时钟对齐到数据对齐的完整调试路径与排查清单,是攻克高速数据采集系统中多片ADC同步难题的实用指南。

weixin_29231725的博客 197

POJ 3331 The Idiot of the Year Contest! 可能会

woniupengpeng的专栏 267

STC8G1K08A的10位PWM避坑指南:为什么你的占空比调节总失效?(附寄存器操作时序图)

本文深入剖析了STC8G1K08A单片机10位PWM功能中占空比调节失效的核心原因,揭示了数据手册未明确指出的寄存器操作时序陷阱。通过对比错误与正确配置的波形,文章指出关键在于更新占空比高2位前需临时关闭PWM输出,并提供了经过验证的安全操作宏与函数库,帮助开发者彻底解决此问题,实现0%-100%的平滑控制。

yyy34的博客 747

2026年信创系统技术应用专业人才培养基地建设方案(高职、信创新专业、人才培养、专业代码:510221)

响应国家信创产业战略及教育部新增“信创系统技术应用”专业(代码510221)的部署,联合麒麟软件、华为鸿蒙等领军企业,建设高水平信创人才培养基地。方案基于国家政策导向(如2027年央企全面国产化替代目标)和行业人才缺口(2025年缺口超80万人),提出以“产教融合、创新驱动”为核心,构建集教学、实训、认证于一体的综合性培养体系。 建设内容涵盖五大方向: 专业规划:分三阶段(2025-2030年)推进专业申报、课程开发与区域辐射,最终建成区域性信创技术创新平台。 课程体系:围绕运维、云计算、数据库、适配

啊碧根果的博客 1597

POJ3331解题报告 高精度幂

The Idiot of the Year Contest!Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 3074 Accepted: 1591DescriptionThere is just one basic rule in the Idiot of the Year Contest (IYC)! The contestant picks a random digit between 0 and 9, computes the fac

施工中请绕行 980

Anomalib实战:从零开始构建自定义数据集的异常检测模型

本文详细介绍了如何使用Anomalib 2.1.0从零开始构建自定义数据集的异常检测模型。通过实战演示,指导读者准备符合规范的数据集结构,快速上手训练Patchcore等先进算法,并完成模型推理与调优,为工业质检、医疗影像等场景提供高效的视觉异常检测解决方案。

weixin_29165465的博客 109

POJ-3331(阶乘高精度,大数乘法一定要用个中间数组啊)

rt

famousDT的专栏 549

我用 Claude Code 给 Spring Boot 老项目做了一次代码 Review:查出 4 类隐藏问题

接手 Spring Boot 老项目时,真正麻烦的往往不是编译报错,而是分散在业务代码中的空指针、N+1 查询、异常吞没和并发隐患。本文记录一次使用 Claude Code 辅助代码 Review 的完整流程,并给出提示词、Java 示例、修改方案和人工复核方法。

海波的专栏 398

图神经网络实战(8)——图注意力网络(Graph Attention Networks, GAT)

图注意力网络 (Graph Attention Networks, GAT) 是对图卷积网络 (Graph Convolutional Network, GCN) 的改进,提出了一种通过自注意力 (self-attention) 过程计算的加权因子,而不是使用静态的归一化系数。在本节中,我们介绍了 GAT 架构。通过从线性变换到多头注意力的四个主要步骤,了解了 GAT 的工作原理,并在 NumPy 中从零开始构建了 GAT 层。最后,将 GAT 模型应用于 Cora 和 CiteSeer 数据集。

盼小辉丶的博客 1万+

poj3331--------------------高精度

一直觉得高精度麻烦,一直在找各种高精度的解决办法,网上搜了一下,java写太帅了!!!!太神奇了 import java.io.*; import java.util.*; import java.math.*; public class Main { static public void main(String[] args) { Scanner ci

*Small eyes-Big world 537

Android 13 wificond讲解

Android 13 wificond讲解

专业开发者的博客,一个从事Android WiFi和蓝牙的工程师 2932

POJ 3331 The Idiot of the Year Contest! 高精度阶乘

http://poj.org/problem?id=3331 The Idiot of the Year Contest! Time Limit:2000MS Memory Limit:65536K Total Submissions:3072 Accepted:1590 Description There is just one basi...

suoyihen 126

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

poj 3331 关于阶乘运算

题意是让求给定一个天数的阶乘,看这个大数中有多少个dight; #include<iostream>#include<string>using namespace std; int flag[1000]; int main(){ int N,day,digit,c,sum; cin>>N; while(N--) { memset(fl...

weixin_34081595的博客 156

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

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

UVa-1225 - Digit Counting

Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 times each digit (0 to 9) appears in the seque

TcD的博客 374

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

poj3663 Costume Party

Costume Party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11793   Accepted: 4770 Description It's Halloween! Farmer John is taking the cows to a costum

Jinbao 2142

金色十月线上编程比赛第一题:小女孩数数

金色十月线上编程比赛第一题:小女孩数数 题目详情: 【金色十月线上编程比赛规则】 一个小女孩正在用左手手指数数,从1数到n。她从拇指算作1开始数起,然后,食指为2,中指为3,无名指为4,小指为5。接下来调转方向,无名指算作6,中指为7,食指为8,大拇指为9,如此反复。问最后会停在那个手指上?用编号1、2、3、4、5依次表示大拇指、食指、中指、无名指、小指。 输入格式

Jinbao 2104

hdu4565 So Easy!(矩阵快速幂)

题意: 告诉你a,b,n,m,求 0 解题思路:     我们首先对(a+sqrt(b))^n进行处理,由a+sqrt(b))^n的展开式我们可以知道 (a+sqrt(b))^n = Xn + Yn * sqrt(b); 那么 ( a + sqrt( b ) )^( n + 1 ) = ( a + sqrt( b ) ) * ( Xn + Yn * sqrt(b) ) = (

Jinbao 1865

四川大学线下编程比赛第一题:数字填充

四川大学线下编程比赛第一题:数字填充 发布公司: 有 效 期: 优快云 2014-09-27至2015-09-26 难 度 等 级: 答 题 时 长: 编程语言要求: 120分钟 C C++ Java C# 题目详情 peter喜欢玩数字游戏,但数独这样的游戏对他来说太简单了,于是他准备玩一个难的游戏。游戏规则

Jinbao 1764

线段树多lazy-tag(两个)

线段树多lazy-tag(两个)题意:有长为N的数列,不妨设为a1,a2,…,aN 。有如下三种操作形式: (1)把数列中的一段数全部乘一个值; (2)把数列中的一段数全部加一个值; (3)询问数列中的一段数的和,由于答案可能很大,你只需输出这个数模P的值。 解题思路: 结构体定义:typdef long long ll; struct Node{ int l,r; l

Jinbao 1587

四川大学线下编程比赛第二题:Peter的X

四川大学线下编程比赛第二题:Peter的X 发布公司: 有 效 期: 优快云 2014-09-27至2015-09-26 难 度 等 级: 答 题 时 长: 编程语言要求: 120分钟 C C++ Java C# 题目详情 Peter是个小男孩,他总是背不清26个英文字母。于是,刁钻的英语老师给他布置了一个非常

Jinbao 1455

poj 3618 Exploration

Exploration Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3826   Accepted: 1850 Description Bessie is traveling on a road teeming with interesting landma

Jinbao 1391

金色十月线上编程比赛第二题:解密

金色十月线上编程比赛第二题:解密 发布公司: 有 效 期: 优快云 2014-10-20至2015-10-20 难 度 等 级: 答 题 时 长: 编程语言要求: 120分钟 C C++ Java C# 题目详情 小强是一名学生, 同时他也是一个黑客。 考试结束后不久,他惊讶的发现自己的高等数学科目居然挂了,于

Jinbao 1275
上一篇: poj 1611 The Suspects
下一篇: poj 2413 How many Fibs?
JinbaoSite0144
博客等级 码龄12年 231粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值