Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
cpp
main.cpp 2.9 kB 1 20-Aug-2015 17:35 filip_bujaroski Множење, Олимпијада

This page (revision-8) was last changed on 20-Aug-2015 17:35 by filip_bujaroski

This page was created on 20-Aug-2015 17:35 by bedzo

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 76 added one line
!!Спојување
At line 78 added 66 lines
%%prettify
{{{
#include <iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<fstream>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<algorithm>
#include<cmath>
#include<math.h>
#define pb push_back
#define MS(a,y) memset(a,y,sizeof(a))
using namespace std;
int main()
{
int n,nzs=0,gol=0;
cin>>n;
string niz[1010],naz[1010];
for(int i=0;i<n;i++)
{
cin>>niz[i];
naz[i]=niz[i];
if(gol<niz[i].size())
gol=niz[i].size();
}
nzs=gol;
stringstream res;
for(int i=0;i<n;i++)
{
int z=niz[i].size();
while(nzs%z!=0) nzs+=gol;
}
for(int i=0;i<n;i++)
{
gol=nzs/niz[i].size();
while(gol--)
{
naz[i]+=niz[i];
}
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(naz[i]<naz[j])
{
swap(niz[i],niz[j]);
swap(naz[i],naz[j]);
}
}
}
for(int i=0;i<n;i++) res<<niz[i];
cout<<res.str()<<endl;
return 0;
}
}}}
/%
At line 237 added 54 lines
!!Оценување
%%prettify
{{{
#include <iostream>
#include<string>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
long long n,k,ar[31],ans=LONG_LONG_MAX;
bool cc(long long a)
{
long long t = 0;
for(int i=0;i<n;i++) t+=a/ar[i];
if(t>=k) {
ans=min(a,ans);
return true;
}
return false;
}
void BS(long long a, long long b)
{
long long c=(a/2)+(b/2);
bool t=cc(c);
if(a!=b & c!=a & c!=b)
{
if(t)
{
BS(a,c);
}
else
{
BS(c,b);
}
}
}
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++) cin>>ar[i];
BS(0,LONG_LONG_MAX);
cout<<ans<<endl;
return 0;
}
}}}
/%
At line 191 changed one line
int main()
char mat[310][310];
int n,m,pi,pj,ei,ej,ans=999999;
int dp[310][310][4];
queue<int> qi,qj,qc,t;
void input()
At line 193 removed one line
int n,m,pi,pj,ei,ej;
At line 195 removed one line
char mat[310][310];
At line 212 changed one line
int dp[310][310][4];
}
void output()
{
for(int i=1;i<4;i++) if(dp[ei][ej][i]!=-1) ans=min(ans,dp[ei][ej][i]);
cout<<ans<<endl;
}
bool isvalid(int r,int i, int j,int ri, int rj,int c)
{
for(int k=1;k<=r;k++)
{
int ni=i+ri*k,nj=j+rj*k;
if(ni<0 || ni>=n || nj<0 || nj>=m) return false;
if(mat[ni][nj]=='#') return false;
}
return true;
}
void bfs()
{
int i,j,k,l;
At line 214 changed one line
queue<int> qi,qj,qc,t;
At line 225 changed 2 lines
if(r==1)
{
At line 229 changed 11 lines
int ni=i+di[k],nj=j+dj[k];
if(ni>=0 & ni<n & nj>=0 & nj<m)
if(dp[ni][nj][r]==-1 | c+1<dp[ni][nj][r])
if(mat[ni][nj]!='#')
{
dp[ni][nj][r]=c+1;
qi.push(ni);
qj.push(nj);
qc.push(c+1);
t.push(2);
}
int ni=i+di[k]*r,nj=j+dj[k]*r;
if(isvalid(r,i,j,di[k],dj[k],c))
if(dp[ni][nj][r]==-1 || c+1<dp[ni][nj][r])
{
dp[ni][nj][r]=c+1;
qi.push(ni);
qj.push(nj);
qc.push(c+1);
t.push(r%3+1);
}
At line 383 added 60 lines
}
}
int main()
{
input();
bfs();
output();
return 0;
}
}}}
/%
--Филип Беџовски
!! Множење, Олимпијада
{{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;
int gol=0;
string mn(string a,string b)
{
string s;
int i,j,k;
vector<string> n,m;
k=b.size();
for(i=a.size()-1; i>=0; i--)
{
string tmp="0";
for(j=0;j<=b.size();j++)
tmp+='0';
for(j=b.size()-1; j>=0; j--)
{
int k=a[i]-48;
int q=b[j]-48;
k*=q;
tmp[j+1]+=(k%10);
tmp[j]+=(k/10);
while(tmp[j+1]>'9')
{
tmp[j+1]-=10;
tmp[j]++;
}
while(tmp[j]>'9')
{
tmp[j-1]++;
tmp[j]-=10;
}
At line 242 changed one line
else if(r==2)
string uber;
for(j=0; j<=k+3; j++)
uber+='0';
tmp=uber+tmp;
int size=tmp.size();
gol=max(gol,size);
while(tmp.size()<gol-1)
tmp+='0';
k--;
n.push_back(tmp);
}
s=n[0];
s.resize(gol*gol);
for(i=1; i<n.size(); i++)
{
string tmp=n[i];
for(j=n[i].size()-1; j>0; j--)
At line 244 changed 15 lines
for(k=0;k<4;k++){
int ti=i+di[k],tj=j+dj[k];
if(ti<0 | ti>=n | tj<0 | tj>=m) continue;
if(mat[ti][tj]=='#') continue;
int ni=i+di[k]*2,nj=j+dj[k]*2;
if(ni>=0 & ni<n & nj>=0 & nj<m)
if(dp[ni][nj][r]==-1 | c+1<dp[ni][nj][r])
if(mat[ni][nj]!='#')
{
dp[ni][nj][r]=c+1;
qi.push(ni);
qj.push(nj);
qc.push(c+1);
t.push(3);
}
if(s[j]>'9')
{
s[j]-=10;
s[j-1]++;
At line 467 added 52 lines
s[j]+=tmp[j]-48;
if(s[j]>'9')
{
s[j]-=10;
s[j-1]++;
}
if(s[j-1]>'9')
{
s[j-2]++;
s[j-1]-=10;
}
}
}
// for(i=1;i<)
return s;
}
long long toint(string s)
{
int k=0;
int mn=1;
reverse(s.begin(),s.end());
int j=s.size()-1;
while(j>=0)
{
k+=s[j]-48;
k*=10;
j--;
}
k/=10;
return k;
}
int main()
{
int m;
m=0;
int i,j,k;
int niza[10];
vector<int> v;
for(i=1; i<=9; i++)
{
cin>>niza[i];
m+=niza[i];
}
for(i=1; i<=9; i++)
{
for(j=0; j<niza[i]; j++)
{
v.push_back(i);
At line 520 added 14 lines
}
reverse(v.begin(),v.end());
string prv,vtor;
prv+=v[0]+48;
for(i=1; i<v.size(); i++)
{
if(prv.size()<vtor.size())
{
prv+=v[i]+48;
}
else if(prv.size()>vtor.size())
{
vtor+=v[i]+48;
}
At line 263 changed 19 lines
for(k=0;k<4;k++){
int ti=i+di[k],tj=j+dj[k];
if(ti<0 | ti>=n | tj<0 | tj>=m) continue;
if(mat[ti][tj]=='#') continue;
ti=i+di[k]*2,tj=j+dj[k]*2;
if(ti<0 | ti>=n | tj<0 | tj>=m) continue;
if(mat[ti][tj]=='#') continue;
int ni=i+di[k]*3,nj=j+dj[k]*3;
if(ni>=0 & ni<n & nj>=0 & nj<m)
if(dp[ni][nj][r]==-1 | c+1<dp[ni][nj][r])
if(mat[ni][nj]!='#')
{
dp[ni][nj][r]=c+1;
qi.push(ni);
qj.push(nj);
qc.push(c+1);
t.push(1);
}
}
if(prv>vtor)
vtor+=v[i]+48;
else prv+=v[i]+48;
At line 540 added one line
At line 284 changed 3 lines
int ans=999999;
for(i=1;i<4;i++) if(dp[ei][ej][i]!=-1) ans=min(ans,dp[ei][ej][i]);
cout<<ans<<endl;
long long x=toint(prv);
x*=toint(vtor);
string s=mn(prv,vtor);
bool okej=false;
string res;
int to;
for(i=0;i<gol-1;i++)
{
if(s[i]!='0')
{
okej=true;
}if(okej)
cout<<s[i];
}
At line 562 added one line
At line 290 removed one line
/%
At line 293 changed one line
--Филип Беџовски
-- Bujo
Version Date Modified Size Author Changes ... Change note
8 20-Aug-2015 17:35 9.808 kB filip_bujaroski to previous
7 20-Aug-2015 17:35 6.838 kB bedzo to previous | to last
6 20-Aug-2015 17:35 5.588 kB bedzo to previous | to last
5 20-Aug-2015 17:35 5.47 kB bedzo to previous | to last
4 20-Aug-2015 17:35 6.684 kB bedzo to previous | to last
3 20-Aug-2015 17:35 5.873 kB bedzo to previous | to last
2 20-Aug-2015 17:35 5.851 kB bedzo to previous | to last
1 20-Aug-2015 17:35 0.516 kB bedzo to last
« This page (revision-8) was last changed on 20-Aug-2015 17:35 by filip_bujaroski