#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
char a[1001];
int b[1001],c[1001],bp,cp,d;
while(cin>>a){
if(a[0]=='0'){
break;
}
for(int x=0;x<strlen(a);x++){
b[x]=a[x]-48;
}
bp=strlen(a);
d=0;
if(bp==1){
d++;
}
while(bp>1){
memset(c,0,sizeof(c));
cp=1;
for(int x=0;x<bp;x++){
c[0]=c[0]+b[x];
for(int y=0;y<cp;y++){
if(c[y]>=10){
cp++;
c[y+1]=c[y+1]+(c[y]/10);
c[y]=c[y]%10;
}
}
}
memset(b,0,sizeof(b));
for(int x=0;x<cp;x++){
b[x]=c[x];
}
bp=cp;
d++;
}
if(b[0]%9==0){
cout<<a<<" is a multiple of 9 and has 9-degree "<<d<<".";
}else{
cout<<a<<" is not a multiple of 9.";
}
cout<<endl;
}
system("pause");
return 0;
}
中學生Lee的的小窩
2018年1月18日 星期四
UVA Q10878 - Decode the tape
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main() {
char a[11],d;
int b,c;
gets(a);
while (gets(a)) {
c=7;
b=0;
if (a[0] == '|') {
for(int x=1;x<=9;x++){
if(a[x]!='.'){
if(a[x]=='o'){
b=b+pow(2,c);
}
c--;
}
}
d=b;
cout<<d;
}else if(a[0]=='_'){
break;
}
}
system("pause");
return 0;
}
#include<cmath>
#include<string>
using namespace std;
int main() {
char a[11],d;
int b,c;
gets(a);
while (gets(a)) {
c=7;
b=0;
if (a[0] == '|') {
for(int x=1;x<=9;x++){
if(a[x]!='.'){
if(a[x]=='o'){
b=b+pow(2,c);
}
c--;
}
}
d=b;
cout<<d;
}else if(a[0]=='_'){
break;
}
}
system("pause");
return 0;
}
UVA Q10812 - Beat the Spread!
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b,c,d,e;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b>>c;
if((b+c)%2==0&&(b-c)%2==0&&(b+c)>=0&&(b-c)>=0){
cout<<(b+c)/2<<" "<<(b-c)/2;
}else{
cout<<"impossible";
}
cout<<endl;
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b,c,d,e;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b>>c;
if((b+c)%2==0&&(b-c)%2==0&&(b+c)>=0&&(b-c)>=0){
cout<<(b+c)/2<<" "<<(b-c)/2;
}else{
cout<<"impossible";
}
cout<<endl;
}
system("pause");
return 0;
}
2018年1月14日 星期日
Win32程式 - 透過tcp傳送keylog的keylogger
因為小編剛學 winsock,然後又看到無線傳輸的keylogger不是要錢就是崁病毒,靈機一動寫了個keylogger。(Github裡有說明)
連結:(下載後用visual studio編譯)
https://github.com/chenlicpp/tcpkeylogger
連結:(下載後用visual studio編譯)
https://github.com/chenlicpp/tcpkeylogger
2018年1月13日 星期六
UVA Q10784 - Diagonal
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int is(double a){
return a==(int)a;
}
int main(){
long long int a,c=1,d;
long double b;
while(cin>>a){
if(a==0){
break;
}
b=((3+sqrt(9+(8*a)))/2);
if(is(b)){
d=((3+sqrt(9+(8*a)))/2);
}else{
d=((3+sqrt(9+(8*a)))/2)+1;
}
cout<<"Case "<<c<<": "<<d<<endl;
c++;
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int is(double a){
return a==(int)a;
}
int main(){
long long int a,c=1,d;
long double b;
while(cin>>a){
if(a==0){
break;
}
b=((3+sqrt(9+(8*a)))/2);
if(is(b)){
d=((3+sqrt(9+(8*a)))/2);
}else{
d=((3+sqrt(9+(8*a)))/2)+1;
}
cout<<"Case "<<c<<": "<<d<<endl;
c++;
}
system("pause");
return 0;
}
UVA Q10783 - Odd Sum
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long int a,b,c,d;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b>>c;
if(b%2==0){
b++;
}else if(c%2==0){
c--;
}
d=0;
for(int y=b;y<=c;y=y+2){
d=d+y;
}
cout<<"Case "<<x<<": "<<d<<endl;
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long int a,b,c,d;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b>>c;
if(b%2==0){
b++;
}else if(c%2==0){
c--;
}
d=0;
for(int y=b;y<=c;y=y+2){
d=d+y;
}
cout<<"Case "<<x<<": "<<d<<endl;
}
system("pause");
return 0;
}
UVA Q10633 - Rare Easy Problem
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
unsigned long long int a,b;
while(cin>>a){
if(a==0){
break;
}
b=0;
for(int x=9;x>=0;x--){
if(((10*a)-x)%9==0){
if(b!=0){
cout<<" ";
}
b++;
cout<<((10*a)-x)/9;
}
}
cout<<endl;
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
unsigned long long int a,b;
while(cin>>a){
if(a==0){
break;
}
b=0;
for(int x=9;x>=0;x--){
if(((10*a)-x)%9==0){
if(b!=0){
cout<<" ";
}
b++;
cout<<((10*a)-x)/9;
}
}
cout<<endl;
}
system("pause");
return 0;
}
Q 10591 - Happy Number
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long int a,b,c,d;
cin>>a;
for(int x=1;x<=a;x++){
cin>>c;
b=c;
while(1){
d=0;
while(c){
d=d+((c%10)*(c%10));
c=c/10;
}
c=d;
if(c==1){
cout<<"Case #"<<x<<": "<<b<<" is a Happy number."<<endl;
break;
}else if(c==4){
cout<<"Case #"<<x<<": "<<b<<" is an Unhappy number."<<endl;
break;
}
}
}
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long int a,b,c,d;
cin>>a;
for(int x=1;x<=a;x++){
cin>>c;
b=c;
while(1){
d=0;
while(c){
d=d+((c%10)*(c%10));
c=c/10;
}
c=d;
if(c==1){
cout<<"Case #"<<x<<": "<<b<<" is a Happy number."<<endl;
break;
}else if(c==4){
cout<<"Case #"<<x<<": "<<b<<" is an Unhappy number."<<endl;
break;
}
}
}
return 0;
}
UVA Q10499 - The Land of Justice
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long a;
while(cin>>a){
if(a==-1){
break;
}
if(a==1){
cout<<"0%"<<endl;
}else{
cout<<a*25<<"%"<<endl;
}
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long a;
while(cin>>a){
if(a==-1){
break;
}
if(a==1){
cout<<"0%"<<endl;
}else{
cout<<a*25<<"%"<<endl;
}
}
system("pause");
return 0;
}
UVA Q10370 - Above Average
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
int a,b,c[1000];
double d,e,f;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b;
f=0;
for(int y=0;y<b;y++){
cin>>c[y];
d=d+c[y];
}
d=d/b;
for(int y=0;y<b;y++){
if(c[y]>d){
f++;
}
}
e=f/b*100;//(¹FŒÐ/Á`€HŒÆ)*100%
cout<<setprecision(3)<<fixed<<e<<"%"<<endl;
}
system ("pause");
return 0;
}
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
int a,b,c[1000];
double d,e,f;
cin>>a;
for(int x=1;x<=a;x++){
cin>>b;
f=0;
for(int y=0;y<b;y++){
cin>>c[y];
d=d+c[y];
}
d=d/b;
for(int y=0;y<b;y++){
if(c[y]>d){
f++;
}
}
e=f/b*100;//(¹FŒÐ/Á`€HŒÆ)*100%
cout<<setprecision(3)<<fixed<<e<<"%"<<endl;
}
system ("pause");
return 0;
}
UVA Q10346 - Peter's Smokes
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
unsigned long long int a,b,c;
while(cin>>a>>b){
c=0;
while(a>=b){
c=c+b;
a=a-b;
a++;
}
cout<<c+a<<endl;
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
unsigned long long int a,b,c;
while(cin>>a>>b){
c=0;
while(a>=b){
c=c+b;
a=a-b;
a++;
}
cout<<c+a<<endl;
}
system("pause");
return 0;
}
UVA Q10340 - All in All
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char a[1000],b[1000];
int c;
bool d;
while(cin>>a>>b){
c=0;
d=0;
for(int x=0;x<strlen(b);x++){
if(a[c]==b[x]){
c++;
if(c==strlen(a)){
d=1;
break;
}
}
}
if(d==0){
cout<<"No"<<endl;
}else{
cout<<"Yes"<<endl;
}
}
system("pause");
return 0;
}
UVA Q10327 - Flip Sort
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b[1000],c,m,d,e;
while(cin>>a){
for(int x=0;x<a;x++){
cin>>b[x];
}
m=0;
while(1){
e=m;
for(c=0;c<a-1;c++){
if(b[c+1]<b[c]){
d=b[c+1];
b[c+1]=b[c];
b[c]=d;
m++;
}
}
if(m==e){
cout<<"Minimum exchange operations : "<<m<<endl;
break;
}
}
}
system("pause");
return 0;
}
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b[1000],c,m,d,e;
while(cin>>a){
for(int x=0;x<a;x++){
cin>>b[x];
}
m=0;
while(1){
e=m;
for(c=0;c<a-1;c++){
if(b[c+1]<b[c]){
d=b[c+1];
b[c+1]=b[c];
b[c]=d;
m++;
}
}
if(m==e){
cout<<"Minimum exchange operations : "<<m<<endl;
break;
}
}
}
system("pause");
return 0;
}
訂閱:
意見 (Atom)