Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

RGB7002 - Гурвалжин

Өгөгдсөн гурвалжны периметрийг ол.

Input

Гурвалжны талууд бүхэл тоогоор нэг мөрөнд зайгаар тусгаарлагдан өгөгдөнө.

Output

Гурвалжны периметр.

Example

Input:
3 4 5

Output:
12


Нэмсэн:Bataa
Огноо:2011-01-15
Хугацааны хязгаарлалт:1s
Эх кодын хэмжээний хязгаарлалт:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Програмчлалын хэлүүд:ADA95 ASM32 BASH BF C NCSHARP CSHARP C++ 4.3.2 CPP C99 CLPS LISP sbcl LISP clisp D ERL FORTRAN HASK ICON ICK JAVA JS-RHINO JULIA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON PYPY3 PYTHON3 RUBY SCALA SCM guile ST TCL WHITESPACE

hide comments
2019-07-04 17:23:47
https://sg.acolytefight.io/?party=p32-eda2

Last edit: 2019-07-05 09:32:12
2019-04-06 11:53:50
#include<bits/stdc++.h>
using namespace std;
long long k=1,ans,a[123],b[123],d,e,i,j,n,c;
string s,s1;
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
cin>>s;
a[0]=0;
b[0]=0;
for(i=0;i<s.size();i++){

if(s[i]=='A'){
a[k]=a[k-1]+1;
b[k]=b[k-1];
}
else{
b[k]=b[k-1]+1;
a[k]=a[k-1];
}
k++;
}
for(i=0;i<=s.size();i++){
for(j=i+1;j<=s.size();j++){
if(a[j]-a[i]==b[j]-b[i]){
ans++;
//cout<<i<<" "<<j<<endl;
}
}
}
cout<<ans;
}
ABAB
2019-04-05 12:37:59
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mk make_pair
#define pb push_back
#define ios ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
ll sum1,sum2,a,b,t,c[1234567],ans,d[1234567],e[1234567],r,i,j,n;
vector<char> v3,v2,v,v1;
int main(){
ios
string s3,s2,s,s1;
cin>>s;
a=s.size();
ans=s.size()-1;
while(s.size()>0){
s1=s;
reverse(s1.begin(),s1.end());
if(s==s1){
cout<<a-s.size();
exit(0);
}
s.erase(s.begin());
}
}
2019-04-04 12:07:26
#include<bits/stdc++.h>
using namespace std;
#define mk make_pair
#define ll long long
#define ios ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
ll a[100][100],n,m,c,d,e,i,j,x,y,xx,yy;
pair<ll,ll> b[100][100];
queue< pair < ll,ll> > q;
int main(){
ios
cin>>x>>y>>xx>>yy;
q.push(mk(x,y));
for(i=1;i<=100;i++){
for(j=1;j<=100;j++){
a[i][j]=9999;
}
}
a[x][y]=0;
while(!q.empty()){
n=q.front().first;
m=q.front().second;
if(n<1 || m<1 || n>10 || m>10 ) q.pop();
else{
if(n==xx&&m==yy){ break; }
if(a[n+1][m+2]==9999){
q.push(mk(n+1,m+2));
b[n+1][m+2]=mk(n,m);
a[n+1][m+2]=a[n][m]+1;
}
if(a[n+1][m-2]==9999){
q.push(mk(n+1,m-2));
b[n+1][m-2]=mk(n,m);
a[n+1][m-2]=a[n][m]+1;
}
if(a[n-1][m+2]==9999){
q.push(mk(n-1,m+2));
b[n-1][m+2]=mk(n,m);
a[n-1][m+2]=a[n][m]+1;
}
if(a[n-1][m-2]==9999){
q.push(mk(n-1,m-2));
b[n-1][m-2]=mk(n,m);
a[n-1][m-2]=a[n][m]+1;
}
if(a[n+2][m+1]==9999){
q.push(mk(n+2,m+1));
b[n+2][m+1]=mk(n,m);
a[n+2][m+1]=a[n][m]+1;
}
if(a[n+2][m-1]==9999){
q.push(mk(n+2,m-1));
b[n+2][m-1]=mk(n,m);
a[n+2][m-1]=a[n][m]+1;
}
if(a[n-2][m+1]==9999){
q.push(mk(n-2,m+1));
b[n-2][m+1]=mk(n,m);
a[n-2][m+1]=a[n][m]+1;
}
if(a[n-2][m-1]==9999){
q.push(mk(n-2,m-1));
b[n-2][m-1]=mk(n,m);
a[n-2][m-1]=a[n][m]+1;
}
q.pop();
}
}
cout<<a[xx][yy]<<endl;
cout<<xx<<" "<<yy<<endl;
while(b[xx][yy].first!=x && b[xx][yy].second!=y){
cout<<b[xx][yy].first<<" "<<b[xx][yy].second<<endl;
n=b[xx][yy].first;
m=b[xx][yy].second;
xx=n;
yy=m;
}
cout<<x<<" "<<y;
}
2019-04-04 06:20:24
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
main()
{ int a[100];
int k,m,j,i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",a[i]);
for(i=1;i<=n;i++)
printf("%5d\n",a[i]);
for(i=1;i>=2;i--)
k=i; m=a[i];
for(j=1;j<=i-1;j--)
if(a[j]>m)
k=j;
m=a[n];
if(k!=i){
a[k]=a[i];
a[i]=m;
} for(i=1;i<=n;i++)
printf("%5d\n",a[i]);
system("pause");
}
2019-04-04 05:14:34
#include<bits/stdc++.h>
using namespace std;
long long q[123456],sum=INT_MAX,ans,m,p,res,c[1234567],b,a[1234567],l[1234567],r[1234567],i,j,n;
string s,s1;
vector<long long> v;
int main(){
cin>>n>>m;
for (int i=1;i<=m;i++){
cin>>l[i]>>r[i];
a[r[i]]++;
a[l[i] - 1]--;
}
long long ans=0;
for(i=n;i>=1;i--){
c[i]=ans+a[i];
ans=c[i];
}
for(int i=1;i<=m;i++){
for(int j=l[i];j<=r[i];j++){
c[j]--;
}
ans=0;
for(int p=1;p<=n;p++){
if(c[p]!=0){
ans++;
}
if(c[p]==1){
q[p]=1;
}
else
q[p]=0;
q[p]+=q[p-1];
}
sum=INT_MAX;
for(int p=i+1;p<=m;p++){
sum=min(sum,q[r[p]]-q[l[p]-1]);
}
res=max(res,ans-sum);
for (int k=l[i];k<=r[i];k++)
c[k]++;
}
cout<<res;
}
2019-04-03 14:35:49
bujka bol mash ulun ohin dandaa hool yridg
2019-04-03 14:35:27
harin bi bol jck bi mash cool zaluu
2019-04-03 14:34:38
nmg bujka gdg bi mash tng ohin
2019-04-02 06:17:57
#include<bits/stdc++.h>
using namespace std;
int main(){
long long ans=0,a,b,c,p=1,n,i,k,m,j;
string s;
cin>>s;
k=s.size();
ans=pow(9,k-1);
for(i=0; i<k; i++){
j=p*pow(9,k-i-1)*(s[i]-'1');
ans=max(ans,j);
p=p*(s[i]-'0');
}
cout<<max(ans,p);
}
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.