问题 A: Petr的盒子(初)
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[];
int main(){
int n , x;
scanf("%d",&n);
for(int i = ; i < n ; i ++){
scanf("%d",&x);
a[i] = ;
a[i] *= x;
}
for(int i = ; i < n ; i ++){
scanf("%d",&x);
a[i] *= x;
}
for(int i = ; i < n ; i ++){
scanf("%d",&x);
a[i] *= x;
}
sort(a , a + n);
for(int i = n - ; i >= ; i --){
printf("%d",a[i]);
if(i != ) printf(" ");
else printf("\n");
}
}
#include <stdio.h>
int main( )
{
int i,n,j,t;
scanf("%d",&n);
int x[];
int y[];
int z[];
int V[];
for(i=;i<n;i++)
{scanf("%d",&x[i]);}
for(i=;i<n;i++)
{scanf("%d",&y[i]);}
for(i=;i<n;i++)
{scanf("%d",&z[i]);}
for(i=;i<n;i++)
{V[i]=x[i]*y[i]*z[i];}
for(i=;i<n-;i++)
for(j=i+;j<n;j++)
if(V[i]<V[j])
{t=V[i],V[i]=V[j],V[j]=t;}
for(i=;i<n;i++)
printf("%3d",V[i]);
return ;
}
#include<stdio.h>
int main()
{
int t,n,a[],i,j,b[],c[],d[];
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%d ",&a[i]);
}
for(i=;i<n;i++)
{
scanf("%d",&b[i]);
}
for(i=;i<n;i++)
{
scanf("%d",&c[i]);
}
for(i=;i<n;i++)
{
d[i]=a[i]*b[i]*c[i];
}
for(i=;i<n-;i++)
for(j=;j<n-;j++)
{
if(d[j]<d[j+])
{
t = d[j];
d[j] = d[j+];
d[j+] = t;
}
}
for(i=;i<n;i++)
printf("%d ",d[i]);
return ;
}
问题 B: 初级魔法师(初)
#include <iostream>
using namespace std;
int main(){
int n, m, sum = ;
scanf("%d%d", &n, &m);
for(int i = ; i <= m; ++i){
sum += (n%i);
}
printf("%d\n", sum);
return ;
}
#include<stdio.h>
#define N 1000000000
long int main()
{
long int n,m,i,a=,s;
scanf("%d%d",&n,&m);
for(i=;i<=m;i++)
a=a+n%i;
s=a%(N+);
printf("%d\n",s);
return ;
}
问题 C: Just wanna a bubble of fishes.(初 )
#include <iostream>
using namespace std;
int main(){
double sum = , x, num;
scanf("%lf", &num);
sum = num;
for(int i = ; i < ; ++i){
scanf("%lf", &x);
sum += x;
}
x = sum / 5.0;
printf("%s\n", x < num ? "no" : "yes");
return ;
}
#include <stdio.h>
int main()
{
float a[],ave=;
int i;
for(i=;i<;i++)
{
scanf("%f",&a[i]);
ave=ave+a[i];
}
ave=ave/;
if(ave<=a[]) printf("no");
else printf("yes");
return ;
}
问题D: Paginationaried
#include <stdio.h>
int main(int argc, char *argv[])
{
int i,n,m;
scanf("%d%d",&n,&m);
if(n>&&m<n-&&m>){
printf("%d %d %d(+) %d %d",m-,m-,m,m+,m+);
}
else if(n>=&&m>=n-){
for(i=n-;i<=n;i++)
{
if(i==m)printf("%d(+) ",i);
if(i!=m)printf("%d ",i);
}
}
else if(n>=&&m<=){
for(i=;i<=;i++)
{
if(i==m)printf("%d(+) ",i);
if(i!=m)printf("%d ",i);
}
}
else if(n<){
for(i=;i<=n;i++){
if(i==m)printf("%d(+) ",i);
if(i!=m)printf("%d ",i);
}
}
return ;
}
问题 E: 喵喵大战猪猪侠(初)
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
int* miao = (int*)malloc(sizeof(int) * n);
int* zhu = (int*)malloc(sizeof(int) * n);
for (int i = ; i < n; i++) scanf("%d", miao + i);
for (int i = ; i < n; i++) scanf("%d", zhu + i);
sort(miao, miao + n);
sort(zhu, zhu + n);
int left = ;
int right = n - ;
int win_cnt = ;
for (int i = n - ; i >= ; i--)
{
if (miao[right] > zhu[i])
{
// printf(" win: %d %d\n", miao[right], zhu[i]);
win_cnt++;
right--;
}
else
{
// printf("lose: %d %d\n", miao[left], zhu[i]);
left++;
}
}
printf("%d\n", win_cnt);
return ;
}
#include <iostream>
#include <algorithm>
using namespace std;
int miao[],zhu[];
int n;
int main(){
std::ios::sync_with_stdio(false);
cin >> n;
for(int i= ; i < n; i++){
cin >> miao[i];
}
for(int i = ; i < n; i++){
cin >> zhu[i] ;
}
sort(miao,miao + n);
sort(zhu,zhu + n);
int ans = ,p = -;
int j = n - ;
for(int i = n - ; i >= ; i--){
if (miao[j] > zhu[i] && j != p){
ans ++;
j --;
}else{
p ++;
}
}
cout << ans << endl;
return ;
}
问题 F: 美丽的二进制字符串(初)
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
string s;
cin >> s;
int ans = ;
for(int i = ; i < s.size() - ; i ++){
if(s[i] == '' && s[i - ] == '' && s[i + ] == ''){
ans ++;
s[i + ] = '';
}
}
printf("%d\n",ans);
}
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author hsy
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Task solver = new Task();
solver.solve(1, in, out);
out.close();
}
static class Task {
public void solve(int testNumber, Scanner in, PrintWriter out) {
String s = in.next();
char[] str = s.toCharArray();
int h = 0;
for (int i = 0; i < s.length() - 2; i++) {
if (str[i] == '0' && str[i + 1] == '1' && str[i + 2] == '0') {
h++;
str[i + 2] = '1';
}
}
out.println(h);
}
}
}
print raw_input().count('')