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

洛谷 P1591 阶乘数码-普及-

P1591 阶乘数码

题目描述

n!n!n! 中某个数码出现的次数。

输入格式

第一行为 t(t≤10)t(t \leq 10)t(t10),表示数据组数。接下来 ttt 行,每行一个正整数 n(n≤1000)n(n \leq 1000)n(n1000) 和数码 aaa

输出格式

对于每组数据,输出一个整数,表示 n!n!n!aaa 出现的次数。

输入输出样例 #1

输入 #1

2
5 2
7 0

输出 #1

1
2

solution

数据量很小,直接暴力即可

代码

#include <sstream>
#include "iostream"
#include "cmath"
#include "algorithm"
#include "cstring"
#include "unordered_set"
#include "deque"
#include "stack"
#include "queue"
#include "vector"
#include "unordered_map"using namespace std;const int N = 1e3 + 1;int a[N][10];int res[3000];void mul(int n) {int s = 0;for (int i = 0; i < 2999; i++) {res[i] *= n;res[i] += s;s = res[i] / 10;res[i] %= 10;}int i = 2999;while (res[i] == 0) i--;for (int j = i; j >= 0; j--) {a[n][res[j]]++;}
}int main() {int t, n, x;cin >> t;res[0] = 1;a[1][1] = 1;for (int i = 2; i <= 1000; i++) {mul(i);}for (int i = 0; i < t; i++) {cin >> n >> x;cout << a[n][x] << endl;}return 0;
}

结果

http://www.xdnf.cn/news/1474435.html

相关文章:

  • PyTorch生成式人工智能——深度分层变分自编码器(NVAE)详解与实现
  • 贪心算法应用:基因编辑靶点选择问题详解
  • 【C++】类和对象(三)
  • Git reset 回退版本
  • stunnel实现TCP双向认证加密
  • Custom SRP - Complex Maps
  • 顺丰,途虎养车,优博讯,得物,作业帮,途游游戏,三七互娱,汤臣倍健,游卡,快手26届秋招内推
  • JVM如何排查OOM
  • 01.单例模式基类模块
  • 微信小程序携带token跳转h5, h5再返回微信小程序
  • Knative Serving:ABP 应用的 scale-to-zero 与并发模型
  • 【Python 】入门:安装教程+入门语法
  • 使用 C# .NETCore 实现MongoDB
  • OpenAI新论文:Why Language Models Hallucinate
  • 【黑客技术零基础入门】2W字零基础小白黑客学习路线,知识体系(附学习路线图)
  • 【C++】C++11的可变参数模板、emplace接口、类的新功能
  • 《云原生微服务治理进阶:隐性风险根除与全链路能力构建》
  • 旧电脑改造服务器1:启动盘制作
  • Element-Plus
  • Nestjs框架: 基于权限的精细化权限控制方案与 CASL 在 Node.js 中的应用实践
  • 【Mysql-installer-community-8.0.26.0】Mysql 社区版(8.0.26.0) 在Window 系统的默认安装配置
  • Nikto 漏洞扫描工具使用指南
  • 管家婆辉煌系列软件多仓库出库操作指南
  • Kubernetes (k8s)
  • MySQL连接字符串中的安全与性能参数详解
  • Monorepo 是什么?如何使用并写自己的第三方库
  • 聊聊OAuth2.0和OIDC
  • 音转文模型对比FunASR与Faster_whisper
  • 《sklearn机器学习——聚类性能指标》Contingency Matrix(列联表)详解
  • PlantSimulation 在汽车总装车间配送物流仿真中的应用