hdu2030java
汉字统计
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36782 Accepted Submission(s):
20003
[Hint:]从汉字机内码的特点考虑~
WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa!
import java.util.*;
class Main{
public static void main(String args[])
{Scanner cin=new Scanner(System.in);
int n=cin.nextInt();
cin.nextLine();
while(n-->0)
{String str=cin.nextLine();
byte []s=str.getBytes();
int sum=0;
for(int i=0;i<s.length;i++)
{if(s[i]<0)
sum++;}
System.out.println(sum/2);
}
}
}
汉字的机内码是个负数,但汉字的机内码占两个字节,所以统计汉字的时候要除以2;
hdu2030java的更多相关文章
随机推荐
- Druid :大数据实时处理的开源分布式系统(1)
引言 Druid 是一个快速,近实时的查询海量只读数据的系统.Druid 的目标是可用性要达到100%,即使在部署新代码,或者某些节点 down 机的情况下. Druid 目前支持的单表查询方式和 D ...
- EasyUI 调用getSelections方法只能获取到一行的原因
$('#tt').datagrid({ url: 'GetDataJosn', title: 'DataGrid', width: 800, height: 300, pageSize: 10, id ...
- Android Training精要(二)開啟ActionBar的Overlay模式
在3.0上的實現 <resources> <!-- the theme applied to the application or activity --> <style ...
- Lua和Javascript差异对比
Lua模拟器js方案 1.语法级模拟lua与js语言差异 1.1注释 js 为//,lua为--. 1.2变量js利用val来声明全局变量不存在局部变量,lua则不需要直接定位则为全局变量,local ...
- 火车车次查询-余票查询--Api接口
1.来自12306的火车车次数据 使用12306网站的接口,查询余票.此接口采集自 这里. 全国火车站代号字典,下载 . 火车票余票查询 http://dynamic.12306.cn/otsquer ...
- Chapter 17 Replication
Chapter 17 Replication Table of Contents 17.1 Replication Configuration 17.2 Replication Implementat ...
- linux操作Oracle导入导出dmp数据命令
--清空该表数据 :非索引清空TRUNCATE TABLE GE_INTERFACE_MESSAGE; --数据库导出 指定导出某个用户的所有数据 包括表 索引 序列 存储过程 函数 等exp CX ...
- POJ_2229_Sumsets_(动态规划)
描述 http://poj.org/problem?id=2229 将一个数n分解为2的幂之和共有几种分法? Sumsets Time Limit: 2000MS Memory Limit: 20 ...
- ☀【移动】Google Maps JavaScript API v3
Google Maps JavaScript API v3https://developers.google.com/maps/documentation/javascript/tutorial?hl ...
- SQL Server数据库存在判断语句及系统表简介 转
Transact-SQL Exists Sentences--判断数据库是否存在IF EXISTS(SELECT * FROM master.sysdatabases WHERE name=N'库名' ...