今天A了两题,A和C题,B题第五组测试数据没过去,也在比赛的时候找到原因了。。。
A题就是先输出n然后输出1到n-1一开始就理解错了以为是直接输出n到1,还奇怪为什么他还说是升序,这不是矛盾吗?果然是自己的问题,题目是不会出现矛盾的,。。这样A题就是水题了,只要读懂题目就简单了。。
The Little Elephant enjoys recursive functions.
This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows:
- If x = 1, exit the function.
- Otherwise, call f(x - 1), and then make swap(ax - 1, ax) (swap the x-th and (x - 1)-th elements of a).
The Little Elephant's teacher believes that this function does not work correctly. But that-be do not get an F, the Little Elephant wants to show the performance of its function. Help him, find a permutation of numbers from 1 to n, such that after performing the Little Elephant's function (that is call f(n)), the permutation will be sorted in ascending order.
A single line contains integer n (1 ≤ n ≤ 1000) — the size of permutation.
In a single line print n distinct integers from 1 to n — the required permutation. Numbers in a line should be separated by spaces.
It is guaranteed that the answer exists.
1
1
2
2 1
#include <iostream>
#include<cstdio>
#include<cstring>
int a[1010],b[1010];
using namespace std;
int main()
{
}
C题;
c题的话确实敲了挺久的不过还是为自己把敲代码过程中碰到的问题并能够处理掉而高兴,毕竟自己进步了。。
C 题我是一后面的提示为突破口的,就是判断给定的一组数是否存在只调换<=1次,就会是新得到的数组里的数按照升序排列。。
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could have accidentally changed array a, only if array a can be sorted in no more than one operation of swapping elements (not necessarily adjacent). That is, the Little Elephant could have accidentally swapped some two elements.
Help the Little Elephant, determine if he could have accidentally changed the array a, sorted by non-decreasing, himself.
The first line contains a single integer n (2 ≤ n ≤ 105) — the size of array a. The next line contains n positive integers, separated by single spaces and not exceeding 109, — array a.
Note that the elements of the array are not necessarily distinct numbers.
In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise.
2
1 2
YES
3
3 2 1
YES
4
4 3 2 1
NO
In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".
In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".
In the third sample we can't sort the array in more than one swap operation, so the answer is "NO".
C代码AC
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int b[100001],a[100001],c[100001];
int main()
{
}
B题的话是找他的因子和他本身要有至少一个相同的数?
先把代码贴一下,明天在看看问题出错在哪里。。
The Little Elephant loves numbers.
He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations.
Help the Little Elephant to find the described number.
A single line contains a single integer x (1 ≤ x ≤ 109).
In a single line print an integer — the answer to the problem.
1
1
10
2
#include <iostream>
#include<cstdio>
using namespace std;
#define maxn 1000001
char
int main()
{
}