博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces比赛题A. Nineteen,BThree matrices
阅读量:4035 次
发布时间:2019-05-24

本文共 3894 字,大约阅读时间需要 12 分钟。

1、

题目:

A. Nineteen
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.

For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.

Help her to find the maximum number of "nineteen"s that she can get in her string.

Input

The first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.

Output

Print a single integer — the maximum number of "nineteen"s that she can get in her string.

Sample test(s)
Input
nniinneetteeeenn
Output
2
Input
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
Output
2
Input
nineteenineteen
Output
2

AC代码:

#include
#include
#include
using namespace std;char s[105];int c[30];int main(){ while(scanf("%s",s)!=EOF) { int len=strlen(s); memset(c,0,sizeof(c)); for(int i=0;i

2、

B. Three matrices
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Chubby Yang is studying linear equations right now. He came up with a nice problem. In the problem you are given an n × n matrix W, consisting of integers, and you should find two n × n matrices A and B, all the following conditions must hold:

  • Aij = Aji, for all i, j (1 ≤ i, j ≤ n);
  • Bij =  - Bji, for all i, j (1 ≤ i, j ≤ n);
  • Wij = Aij + Bij, for all i, j (1 ≤ i, j ≤ n).

Can you solve the problem?

Input

The first line contains an integer n (1 ≤ n ≤ 170). Each of the following n lines contains n integers. The j-th integer in the i-th line is Wij (0 ≤ |Wij| < 1717).

Output

The first n lines must contain matrix A. The next n lines must contain matrix B. Print the matrices in the format equal to format of matrix W in input. It is guaranteed that the answer exists. If there are multiple answers, you are allowed to print any of them.

The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 4.

Sample test(s)
Input
21 43 2
Output
1.00000000 3.500000003.50000000 2.000000000.00000000 0.50000000-0.50000000 0.00000000
Input
31 2 34 5 67 8 9
Output
1.00000000 3.00000000 5.000000003.00000000 5.00000000 7.000000005.00000000 7.00000000 9.000000000.00000000 -1.00000000 -2.000000001.00000000 0.00000000 -1.000000002.00000000 1.00000000 0.00000000

Ac代码:

#include
#include
#include
using namespace std;#define N 175double a[N][N],b[N][N],c[N][N];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) scanf("%lf",&a[i][j]); } for(int i=1;i<=n;i++) { b[i][i]=a[i][i]; for(int j=i+1;j<=n;j++) { b[i][j]=b[j][i]=(a[i][j]+a[j][i])/2; c[i][j]=a[i][j]-b[i][j]; c[j][i]=-c[i][j]; } } for(int i=1;i<=n;i++) { int flag=0; for(int j=1;j<=n;j++) { if(flag==0) printf("%.8f",b[i][j]),flag=1; else printf(" %.8f",b[i][j]); } printf("\n"); } for(int i=1;i<=n;i++) { int flag=0; for(int j=1;j<=n;j++) { if(flag==0) printf("%.8f",c[i][j]),flag=1; else printf(" %.8f",c[i][j]); } printf("\n"); } } return 0;}

 

转载地址:http://uwcdi.baihongyu.com/

你可能感兴趣的文章
Maven跳过单元测试的两种方式
查看>>
通过C++反射实现C++与任意脚本(lua、js等)的交互(二)
查看>>
利用清华镜像站解决pip超时问题
查看>>
[leetcode BY python]1两数之和
查看>>
微信小程序开发全线记录
查看>>
Centos import torchvision 出现 No module named ‘_lzma‘
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>