【习题 3-3 UVA-1225】Digit Counting
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
水模拟
【代码】
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
/*freopen("F:\\rush.txt", "r", stdin);*/
int T;
scanf("%d", &T);
while (T--)
{
int n;
scanf("%d", &n);
for (int i = 0; i <= 9; i++) a[i] = 0;
for (int i = 1; i <= n; i++)
{
int x = i;
while (x)
{
a[x % 10]++;
x /= 10;
}
}
for (int i = 0; i <= 9; i++)
{
printf("%d", a[i]);
if (i == 9)
puts("");
else
putchar(' ');
}
}
return 0;
}
【习题 3-3 UVA-1225】Digit Counting的更多相关文章
- UVa 1225 Digit Counting --- 水题
UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...
- UVa 1225 Digit Counting
题意:给出n,将前n个整数顺次写在一起,统计各个数字出现的次数. 用的最笨的办法--直接统计-- 后来发现网上的题解有先打表来做的 #include<iostream> #include& ...
- UVa 1225 - Digit Counting - ACM/ICPC Danang 2007 解题报告 - C语言
1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次. 2.思路 第一想法是打表,然而觉得稍微有点暴力.不过暂时没有想到更 ...
- UVa1587.Digit Counting
题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=247&p ...
- UVA 1640 The Counting Problem UVA1640 求[a,b]或者[b,a]区间内0~9在里面各个数的数位上出现的总次数。
/** 题目:UVA 1640 The Counting Problem UVA1640 链接:https://vjudge.net/problem/UVA-1640 题意:求[a,b]或者[b,a] ...
- uva 11401 Triangle Counting
// uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...
- UVa 1583 Digit Generator --- 水题+打表
UVa 1583 题目大意:如果x加上x的各个数字之和得到y,那么称x是y的生成元. 给定数字n,求它的最小生成元 解题思路:可以利用打表的方法,提前计算出以i为生成元的数,设为d,并保存在a[d]中 ...
- Digit Counting UVA - 1225
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequ ...
- 数数字 (Digit Counting,ACM/ICPC Danang 2007,UVa 1225)
思路: 利用java 特性,将数字从1 一直加到n,全部放到String中,然后依次对strring扫描每一位,使其carr[str.charAt(i)-'0']++; 最后输出carr[i],即可. ...
- UVA1225 - Digit Counting(紫书习题3.3)
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequen ...
随机推荐
- dfs算法中求数列的组合
/* 从13个书中挑选5个值,他们的组合可能是 什么, 如下代码 dfs深度遍历, 和全排列是一种方法,但是思路不同 */ public class Main { static int count = ...
- BZOJ 1355 KMP中next数组的应用
思路: 我们知道 next[i]是失配的i下一步要去哪儿 next[n]就是失配的n要去哪儿 n-next[n]就是答案(即最短周期)啦 //By SiriusRen #include <cst ...
- 用Nagios监控Sql Server服务器
在Suse 下配置Nagios来监控Ms SQL Server操作演示 本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- javafx ComboBox Event and change cell color
public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...
- react-native React Native version mismatch
android/app/build.gradle file: dependencies { compile fileTree(dir: "libs", include: [ ...
- HDU——T 1573 X问题
http://acm.hdu.edu.cn/showproblem.php?pid=1573 Time Limit: 1000/1000 MS (Java/Others) Memory Limi ...
- 在web开发中你不得不注意的安全验证问题#2-XSS
前言 XSS又叫CSS (Cross Site Script) ,跨站脚本攻击. 恶意攻击者往Web页面里插入恶意html代码.当用户浏览该页之时,嵌入当中Web里面的html代码会被运行,从而达到恶 ...
- Service-监听手机来电
public class MonitorPhone extends Activity { TelephonyManager tManager; @Override protected void onC ...
- 自己定义控件的onMeasure方法具体解释
在我们自己定义控件的时候可能你会用到onMeasure方法,以下就具体的给大家介绍一下这种方法: @Override protected void onMeasure(int widthMeasure ...
- ThreadLocal使用演示样例
MainActivity例如以下: package cc.cv; import android.os.Bundle; import android.app.Activity; /** * Demo描写 ...