A Age
Today broccoli with garlic Jun sister and friends gathering together, when asked about the age of my friends, garlic king played a charades (after all, the age of a girl's privacy) said: "My age is the age of a girl broccoli the sum of digits and ten digits twice. "
Broccoli force sister to see you look ignorant, you know we do not know garlic king's age, he quickly added: "My age is garlic king single digits and ten digits of the sum of three times."
Please work: Jun garlic and broccoli girl aged a total number of possible scenarios?
Reminder: two are in the age of [10, 100) within [10,100) this interval.
#include<stdio.h>
int main()
{
int a,b,c,d,x,y;
int i,j,t=0;
for(i=1;i<10;i++)
{
for(j=0;j<10;j++)
{
x=i*10+j;
y=2*(i+j);
if(x==3*((y/10)+(y%10))) t+=1;
}
}
printf("%d",t);
return 0;
}
Violence miracle.
B light switch
Today garlic king returned to the home of the big house, the home of the lamp or lamps that the cable (pulling a bright, once again pull off), garlic king bored. The lamp 33 is a multiple of 10,001,000 pulled once, a fold 55 is pulled, pulling a multiple of 7 (the number of light obtained from 1-10001-1000, the initial state of the lamp is lit). This time thinking about garlic king left a few lights still on?
Tip: Do not output the extra symbols.
#include<stdio.h>
int main()
{
int i,t=0;
for(i=1;i<1001;i++)
{
if(i%3==0&&i%5!=0&&i%7!=0) t+=1;
if(i%5==0&&i%3!=0&&i%7!=0) t+=1;
if(i%7==0&&i%5!=0&&i%3!=0) t+=1;
if(i%3==0&&i%5==0&&i%7==0) t+=1;
}
printf("%d",1000-t);
return 0;
}
Full array C
I believe we all know what a full array, but today's full array than you might think a little difficult. We're looking for the whole arrangement in which the number of results different from each other. For example: the whole arrangement aab on only three, that is, aab, baa, aba.
Code code box is a realization, analyze and fill in the missing code.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 1000
char str[N], buf[N];
int vis[N], total, len;
void arrange(int num) {
int i, j;
if (num == len) {
printf("%s\n", buf);
total++;
return;
}
for (i = 0; i < len; ++i) {
if (!vis[i]) {
for (j = i + 1; j < len; ++j) {
if (str[i] == str[j] && vis[j]) {//这里是填写的代码
break;
}
}
if (j == len) {
vis[i] = 1;
buf[num] = str[i];
arrange(num + 1);
vis[i] = 0;
}
}
}
}
int main() {
while (~scanf("%s", str)) {
len = strlen(str);
int i, j;
for (i = 0; i < len; ++i) {
for (j = i + 1; j < len; ++j) {
if (str[i] > str[j]) {
char tmp = str[i];
str[i] = str[j];
str[j] = tmp;
}
}
}
total = 0;
buf[len] = '\0';
arrange(0);
printf("Total %d\n", total);
}
return 0;
}
Evaluating the number of column D
#include<stdio.h>
double a[1005];
int main()
{
int n;
double an1,c;
scanf("%d",&n);
scanf("%lf%lf",&a[0],&an1);
a[1]=0;
for(int i=2;i<=n+1;i++)
{
scanf("%lf",&c);
a[i]=2*a[i-1]-a[i-2]+2*c;
}
printf("%.2f\n",(an1-a[n+1])/(n+1));
return 0;
}