At line 1 removed one line |
Еве неофицијални решенија: |
At line 3 removed 248 lines |
!!Прегледување: |
|
!C++ |
%%prettify |
{{{ |
|
#include <iostream> |
using namespace std; |
|
int main() |
{ |
int n, k, kv=0, minvreme=9999999, minkom=9999999; |
cin>>n>>k; |
for(int i=1; i<999999; i++) |
{ |
for(int j=1; j<i; j++) |
{ |
kv+=j; |
} |
if((n%i==0)&&(kv*k+n/i<minvreme)) |
{ |
minvreme=kv*k+n/i; |
} |
else if ((n%i!=0)&&(kv*k+n/i+1<minvreme)) |
minvreme=kv*k+n/i+1; |
//minvreme=kv*k+n%i+n/i; |
else break; |
kv=0; |
minkom=i; |
} |
cout<<minkom; |
return 0; |
} |
}}} |
/% |
|
|
|
!!Регистрација: |
|
!C++ |
%%prettify |
{{{ |
#include <iostream> |
#include <sstream> |
|
using namespace std; |
|
int main() |
{ |
stringstream ss; |
string a, rez, plus; |
int n, plu=1; |
cin>>a>>n; |
rez=a; |
string users[n]; |
for(int i=0; i<n; i++) |
{ |
cin>>users[i]; |
} |
for(int i=0; i<n; i++) |
{ |
if(users[i]==rez) |
{ |
ss<<plu; |
ss>>plus; |
rez=a+plus; |
ss.str(""); |
ss.clear(); |
plu++; |
i=-1; |
} |
} |
cout<<rez; |
return 0; |
} |
}}} |
/% |
|
!!Одземање: |
!C++ |
%%prettify |
{{{ |
|
#include <iostream> |
using namespace std; |
|
void bubblesort(string &a) |
{ |
char tmp; |
for(int i=0; i<a.length(); i++) |
{ |
for(int j=0; j<a.length()-1; j++) |
{ |
if(a[j]>a[j+1]) |
{ |
tmp=a[j]; |
a[j]=a[j+1]; |
a[j+1]=tmp; |
} |
} |
} |
} |
|
void bubblesortrev(string &a) |
{ |
char tmp; |
for(int i=0; i<a.length(); i++) |
{ |
for(int j=0; j<a.length()-1; j++) |
{ |
if(a[j]<a[j+1]) |
{ |
tmp=a[j]; |
a[j]=a[j+1]; |
a[j+1]=tmp; |
} |
} |
} |
} |
|
int main() |
{ |
char min='9'; |
string broj, minbroj; |
cin>>broj; |
minbroj=broj; |
bubblesort(minbroj); |
bubblesortrev(broj); |
for(int i=0; i<broj.length(); i++) |
{ |
if(broj[i]-minbroj[i]+'0'<'0') |
{ |
for(int j=i-1; j>=0; j--) |
{ |
if(broj[j]-1>='0') |
{ |
broj[j]--; |
break; |
} |
else |
{ |
broj[j]='9'; |
} |
} |
broj[i]=broj[i]-minbroj[i]+'9'+1; |
} |
else broj[i]=broj[i]-minbroj[i]+'0'; |
} |
int loc=broj.length()-1; |
for(int i=0; i<broj.length(); i++) |
{ |
if(broj[i]=='0') |
continue; |
else |
{ |
loc=i; |
break; |
} |
} |
for(int i=loc; i<broj.length(); i++) |
{ |
cout<<broj[i]; |
} |
return 0; |
} |
}}} |
/% |
!!Финкимен: |
|
!C++ |
%%prettify |
{{{ |
|
#include <iostream> |
using namespace std; |
|
int r, c, minpole=999999, minr, minc; |
int pole[50][50]; |
|
bool check() |
{ |
for(int i=0; i<r; i++) |
{ |
for(int j=0; j<c; j++) |
{ |
if(pole[i][j]!=-1) |
return false; |
} |
} |
return true; |
} |
|
void findmin() |
{ |
for(int i=0; i<r; i++) |
{ |
for(int j=0; j<c; j++) |
{ |
if((pole[i][j]!=-1)&&(pole[i][j]<minpole)) |
{ |
minpole=pole[i][j]; |
minr=i; |
minc=j; |
} |
} |
} |
} |
|
void fill(int x, int y) |
{ |
int val=pole[x][y]; |
pole[x][y]=-1; |
if((x+1<r)&&(pole[x+1][y]>=val)) fill(x+1, y); |
if((x-1>=0)&&(pole[x-1][y]>=val)) fill(x-1, y); |
if((y+1<c)&&(pole[x][y+1]>=val)) fill(x, y+1); |
if((y-1>=0)&&(pole[x][y-1]>=val)) fill(x, y-1); |
} |
|
int main() |
{ |
int res=0; |
cin>>r>>c; |
for(int i=0; i<r; i++) |
{ |
for(int j=0; j<c; j++) |
{ |
cin>>pole[i][j]; |
if(pole[i][j]<minpole) |
{ |
minr=i; |
minc=j; |
minpole=pole[i][j]; |
} |
} |
} |
while(check()==false) |
{ |
fill(minr, minc); |
res++; |
minpole=999999; |
findmin(); |
} |
cout<<res; |
return 0; |
} |
}}} |
/% |